I'm reconstructing a chronoform form from an older environment to a newer one (4.0 RC3.5.2).
In the onsubmit event I have an action to send mail. The mail is sent OK, but I have a problem with checkboxes that are unchecked. The field name is printed between curly braces (e.g. {checkbox_field}). I'm able to fix that by setting the Replace Nulls parameter to yes. In that case an empty value is printed in the mail message. I prefer to have a null value replaced by the text: "no". So I added a custom code action in the submit event (prior to the Email action), containing the following php code:
<?php
JRequest::setVar('checkbox_field', JRequest::getString('checkbox_field', 'no', 'post'));
?>
The intention is to replace null values with "no", but it doesn't work in the newer environment (it worked in the older chronoform version). Any clues how to solve this? Thanks in advance.
In the onsubmit event I have an action to send mail. The mail is sent OK, but I have a problem with checkboxes that are unchecked. The field name is printed between curly braces (e.g. {checkbox_field}). I'm able to fix that by setting the Replace Nulls parameter to yes. In that case an empty value is printed in the mail message. I prefer to have a null value replaced by the text: "no". So I added a custom code action in the submit event (prior to the Email action), containing the following php code:
<?php
JRequest::setVar('checkbox_field', JRequest::getString('checkbox_field', 'no', 'post'));
?>
The intention is to replace null values with "no", but it doesn't work in the newer environment (it worked in the older chronoform version). Any clues how to solve this? Thanks in advance.
Hi Bob,
Thanks, that would be a great and simple solution. However I don't as such have a checkbox element (in chronoform terms). Instead I have a custom element with html code containing a number of checkboxes in table form (amongst others). See the attached checkboxes.png. The reason why I chose this is because of the layout (in reality the form has more such tables even with select elements etc.), as you may understand if you see the screenshot. Can my issue be solved when using this custom element construction with html code?
Best regards,
mart1jn
Thanks, that would be a great and simple solution. However I don't as such have a checkbox element (in chronoform terms). Instead I have a custom element with html code containing a number of checkboxes in table form (amongst others). See the attached checkboxes.png. The reason why I chose this is because of the layout (in reality the form has more such tables even with select elements etc.), as you may understand if you see the screenshot. Can my issue be solved when using this custom element construction with html code?
Best regards,
mart1jn
Hi mart1jn,
You can get the same effect by adding hidden inputs into your form with the same names as the checkboxes. They must be before the checkboxes in the form HTML.
Or, if you prefer, you can use PHP in a Custom Code action in the On Submit event to check which checkboxes have returned values and set the values of the remainder to 'No'.
Bob
You can get the same effect by adding hidden inputs into your form with the same names as the checkboxes. They must be before the checkboxes in the form HTML.
Or, if you prefer, you can use PHP in a Custom Code action in the On Submit event to check which checkboxes have returned values and set the values of the remainder to 'No'.
Bob
Thanks, Bob. To focus on your second solution (Custom Code action in the On Submit event), this was what I'm trying to get working. See my initial post above. Could we try and get that running?
Rgrds,
mart1jn
Rgrds,
mart1jn
Hi mart1jn,
The equivalent to the old CFv3 code would be:
Bob
The equivalent to the old CFv3 code would be:
<?php
$checkbox_array = array (
'checkbox_field',
// add more checkbox names here
);
foreach ( $checkbox_array as $c ) {
if ( !isset($form->data[$c]) || !$form->data[$c] ) {
$form->data[$c] = 'No';
}
}
?>
Bob
This topic is locked and no more replies can be posted.