Page 1 of 1
How to make attachments required like full name and email fields
Posted: Thu Oct 05, 2017 1:40 pm
by jonatangm
I need to make upload attachments required when submitting tickets on my help desk. I can't find the code to make it required

Re: How to make attachments required like full name and email fields
Posted: Thu Oct 05, 2017 6:37 pm
by Klemen
Haven't tested it, but try adding
Code: Select all
if (empty($attachments) && ! isset($hesk_error_buffer['attachments']))
{
$hesk_error_buffer['attachments'] = 'Please attach a file to your ticket.';
}
just above
in submit_ticket.php
You will also want to add the red asterix on the submit a ticket form in index.php change
Code: Select all
<?php echo $hesklang['attachments']; ?>:
to
Code: Select all
<?php echo $hesklang['attachments']; ?>: <font class="important">*</font>
If you want the same for admin panel, similar code changes will go to admin/new_ticket.php and admin/admin_submit_ticket.php
Re: How to make attachments required like full name and email fields
Posted: Mon Oct 09, 2017 6:56 pm
by jonatangm
thanks for your response, It kinda works, but there is only one thing that it's not working right now, i still able to open a new ticket with no attachments added.

Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 1:10 pm
by karmainsa
Anyone has figure out how to make attachments required?
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 1:56 pm
by Klemen
The code modifications I posted above work for me in Hesk 3.2.5 when submitting tickets from the customer web interface.
Have you tried them?
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 2:33 pm
by karmainsa
Thank you very much for the reply!
Unfortunately no, I can't get it to work. When I don't attach, I get the notice, but attaching I still get the required notice. The notice always appears now, attached or not.
my site is
https://activo.sanlo.gov.py in case you can try and create a ticket to see how it behaves please
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 3:19 pm
by Klemen
I submitted a test ticket with no attachment, so I presume you don't have the modification in place anymore.
Did you try the submit_ticket.php file I emailed you?
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 3:40 pm
by karmainsa
I'm sorry. Considering that it is in production, I removed the modification for a moment. now I put the modification back if you want to try
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 4:40 pm
by Klemen
Found the issue - it showed the same error message, even if the error was a different one (like a file type not allowed).
This part:
Should be:
Code: Select all
if (empty($attachments) && ! isset($hesk_error_buffer['attachments']))
Will fix it in above example too.
Re: How to make attachments required like full name and email fields
Posted: Thu Jun 16, 2022 4:48 pm
by karmainsa
you're right! now it works perfect!!
You saved me! Thank you!! you're very kind!