Tom Wilson Posted June 5, 2019 Share Posted June 5, 2019 Hello! Is there a way to remove the attachment box when creating a ticket if it's being created for department x? Thanks Tom 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted June 5, 2019 Share Posted June 5, 2019 (edited) There are probably better ways and I'm not that good with jQuery but this is how I would do it. Depending on the selected department the script hides/shows attachments section. It also clears any existing attachment when vistors switch department. I tested it on Six template. Use it as a starting point since as I already said my jQuery skills are... 🤢 <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { $deptID = '1'; // Hide Attachment for the given Department ID return <<<HTML <script> $(document).ready(function() { if ($('select#inputDepartment').val() == '{$deptID}') toggleAttachments('show'); else toggleAttachments('hide'); $('#inputDepartment').on('change', function() { if ($('select#inputDepartment').val() == '{$deptID}') toggleAttachments('show'); else toggleAttachments('hide'); }); }); function toggleAttachments(e) { if (e == 'hide') { $('#inputAttachments').closest('.form-group').hide(); $('#inputAttachments').val(''); } if (e == 'show') { $('#inputAttachments').closest('.form-group').show(); } } </script> HTML; }); Edited June 5, 2019 by Kian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 6, 2019 Share Posted June 6, 2019 12 hours ago, Kian said: There are probably better ways and I'm not that good with jQuery but this is how I would do it. if the templates used IDs correctly (or even at all), then CSS would be simpler... but with that flaw to contend with, you're hooking - and I suspect it would have to be JS because the page doesn't refresh on a department change, so Smarty solutions would be limited. 12 hours ago, Kian said: Depending on the selected department the script hides/shows attachments section. It also clears any existing attachment when visitors switch department. I tested it on Six template. I think it shows the attachments for the specified depts, but hides it for others (e.g the reverse of what you want) - it also seems to hide the custom fields too... 12 hours ago, Kian said: Use it as a starting point since as I already said my jQuery skills are... they won't be as bad as mine! 🙄 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.