I have a form am working on but ran into an issues, I am using one of the build-in demo chronoforms named “demo-fields-events” Basic form with conditional fields, disable/enable fields based on user's choices.
There is a radio button with 3 options:
Work
Travel
Other
If “Other” is chosen a text box is shown and you can type in it, if “Work” or “Travel” is chosen the text box is hidden again.
The problem is if the person choose “Other” type some info in it, then decided to change their answer and let’s say go with “Travel” instead and submit the form I get an email with “Travel” selected plus the info in the text box that they typed before when other was chosen.
So how can I fix this so when a field is hidden all info is cleared or reset?
There is a radio button with 3 options:
Work
Travel
Other
If “Other” is chosen a text box is shown and you can type in it, if “Work” or “Travel” is chosen the text box is hidden again.
The problem is if the person choose “Other” type some info in it, then decided to change their answer and let’s say go with “Travel” instead and submit the form I get an email with “Travel” selected plus the info in the text box that they typed before when other was chosen.
So how can I fix this so when a field is hidden all info is cleared or reset?
Hi evilsnoop,
ChronoForms really should know better and delete the contents of any newly hidden elements :-(
I'd use a Custom Code action in the form On Submit event with code like this:
Bob
ChronoForms really should know better and delete the contents of any newly hidden elements :-(
I'd use a Custom Code action in the form On Submit event with code like this:
<?php
if ( $form->data['work_travel'] != 'Other' ) {
$form->data['other'] = '';
}
?>Replace 'work_travel' and 'other' with the correct names of your form elements.
Bob
So I created the custom code and place it under the “on submit event” as the first event but the code don’t work I still get both selected info in the email.
Am not sure what I am doing wrong.
Am not sure what I am doing wrong.
Hi evilsnoop,
Replace 'work_travel' and 'other' with the correct names of your form elements. and the second other with the value of your Other radio-button.
I have no idea what you have used for input names and option values . . .
Bob
Replace 'work_travel' and 'other' with the correct names of your form elements. and the second other with the value of your Other radio-button.
I have no idea what you have used for input names and option values . . .
Bob
As stated before I am using one of the build-in demo chronoforms named “demo-fields-events” Basic form with conditional fields, disable/enable fields based on user's choices.
The only thing I changed was disable debugger and included an email address on submit. And still no luck, if you want access to the test site I can PM you.
The only thing I changed was disable debugger and included an email address on submit. And still no luck, if you want access to the test site I can PM you.
Hi evilsnoop,
As Bob said you have to fill the correct Field Names in the Custom Code of the radio field for the check, and the text field for the reset. In your case thats radio3 for the radio and text4 for the other info textarea.
So try this:
[[> later : replaced 'Other' with 'other' to match values. Bob <<]]
As Bob said you have to fill the correct Field Names in the Custom Code of the radio field for the check, and the text field for the reset. In your case thats radio3 for the radio and text4 for the other info textarea.
So try this:
<?php
if ( $form->data['radio3'] != 'other' ) {
$form->data['text4'] = '';
}
?>
[[> later : replaced 'Other' with 'other' to match values. Bob <<]]
This topic is locked and no more replies can be posted.
