Forums

Remove "required" property if file exists

awgcas 04 May, 2017
Hi to all,
I need to remove the required property in an "upload file" action if a file exists.
Check if file exists is executed via php.

How can I try to complete this task?
Form is based on CF V5.

Thanks
Alessandro
Max_admin 04 May, 2017
Hi Alessandro,

on v5 this is a bit difficult, but it can be done on v6

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 04 May, 2017
Answer
Hi Alessndro,

One way to do it in CFv5 would be to have two File Field elements in your form both with the same name - one required and one not. Then use an Event Switcher to use CSS to show/hide them depending on whether the file exists.

Note that you should check also after the form submits as a blank entry can over-write the saved file info unless you remove it before the DB Save.

Bob
awgcas 04 May, 2017
Thank you Bob, I will give it a try and let you know!

Alessandro
awgcas 17 May, 2017
Thank you Bob, it works!!

Alessandro
This topic is locked and no more replies can be posted.