Hi,
I am seeing {fieldname} appear in the email for radio buttons and checkboxes when nothing is selected. How can I get it to not show up if nothing is selected?
This is the form:
http://www.24-7uksocceracademy.com/index.php?option=com_chronocontact&chronoformname=247CampRegistrationForm3
I know there are similar topics out there, but I've tried looking through the forums for a solution and found nothing that works specifically for me. Any help is greatly appreciated.
I am seeing {fieldname} appear in the email for radio buttons and checkboxes when nothing is selected. How can I get it to not show up if nothing is selected?
This is the form:
http://www.24-7uksocceracademy.com/index.php?option=com_chronocontact&chronoformname=247CampRegistrationForm3
I know there are similar topics out there, but I've tried looking through the forums for a solution and found nothing that works specifically for me. Any help is greatly appreciated.
Hi kko,
The simplest answer to this is to add a code snippet to the OnSubmit Before box. Becasue checkboxes return nothing if they are not checked ChronoForms doesn't know that {fieldname} refers to a form field at all.
This will ensure that all the values in $check_array exist in the form results (those that aren't checked will have value of '' (an empty string).
A slightly more sophisticated version might be:
Bob
PS Not tested and may need debugging!
The simplest answer to this is to add a code snippet to the OnSubmit Before box. Becasue checkboxes return nothing if they are not checked ChronoForms doesn't know that {fieldname} refers to a form field at all.
<?php
$check_array = array(
'field_name_1',
'field_name_2',
'field_name_'
);
foreach ( $check_array as $v ) {
$temp = JRequest::getString($v, '', 'post');
JRequest::setVar($v, $temp);
}
?>
This will ensure that all the values in $check_array exist in the form results (those that aren't checked will have value of '' (an empty string).
A slightly more sophisticated version might be:
<?php
$check_array = array(
'field_name_1' => '',
'field_name_2' => 'No',
'field_name_' => 'Tuesday'
);
foreach ( $check_array as $k => $v ) {
$temp = JRequest::getString($k, $v, 'post');
JRequest::setVar($k, $temp);
}
?>
This will substitute the values from the array for any missing values from the form.Bob
PS Not tested and may need debugging!
Thanks, Bob!
I used the first set of code and it works perfectly.
I'm sure the second snippet will come in handy for my future use.
Thanks again for the help. 😀
I used the first set of code and it works perfectly.
I'm sure the second snippet will come in handy for my future use.
Thanks again for the help. 😀
I also used that first snippet of code - thank you!
Thanks ! I've used the first one as well and it worked.
why not using simply :
?
If checkboxes are ticked, it will display the labels, if not, it'll show nothing !
<?php echo $_POST['checkboxfieldname']; ?>
?
If checkboxes are ticked, it will display the labels, if not, it'll show nothing !
Thanks! I used the "fancier" code and it worked like a charm - appreciated!!
This topic is locked and no more replies can be posted.