I upgraded to ChronoForms V3.1 RC5.5 and it seems this introduced a new problem.
My form has several check boxes. E.g.:
<input type="checkbox" name="hulp_opruimen_donderdag" value="ja" tabindex="53">
In the mail sent by chronoform this used to be printed as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag <empty>
(where <empty> means nothing is printed)
now with rc 5.5 the behaviour is as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag {hulp_opruimen_donderdag}
i.e. it prints the fieldname between braces (is this a bug or is it because i made a mistake?).
my preferred behaviour would be:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag nee
is there a solution to this bug or (better) is there a way to create my preferred behaviour?
Thanks in advance.
My form has several check boxes. E.g.:
<input type="checkbox" name="hulp_opruimen_donderdag" value="ja" tabindex="53">
In the mail sent by chronoform this used to be printed as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag <empty>
(where <empty> means nothing is printed)
now with rc 5.5 the behaviour is as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag {hulp_opruimen_donderdag}
i.e. it prints the fieldname between braces (is this a bug or is it because i made a mistake?).
my preferred behaviour would be:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag nee
is there a solution to this bug or (better) is there a way to create my preferred behaviour?
Thanks in advance.
Hi mart1jn,
I don't know where the <empty> came from.
A checkbox has an entry in the $_POST array if it is checked but not if it isn't. So you'll get back either 'ja' or nothing. You can add a couple of lines of code in the Onsubmit Before box to switch that to 'nee'.
This reads the $_POST array using 'nee' as a default value and re-writes the result back to the $_POST array.
Bob
I don't know where the <empty> came from.
A checkbox has an entry in the $_POST array if it is checked but not if it isn't. So you'll get back either 'ja' or nothing. You can add a couple of lines of code in the Onsubmit Before box to switch that to 'nee'.
<?php
JRequest::setVar('hulp_opruimen_donderdag', JRequest::getString('hulp_opruimen_donderdag', 'nee', 'post'));
?>
Not tested and may need de-bugging!This reads the $_POST array using 'nee' as a default value and re-writes the result back to the $_POST array.
Bob
hi Greyhead,
Thanks, your piece of code works, I do get the "nee" printed with that (after adding an extra ' behind 'post).
You helped my solve that problem. Only the question remains why with rc 5.5 the default behaviour changed, i.e. why is {fieldname} returned by default instead of an empty value when the checkbox isn't checked. It would be nice if that default behaviour would still work.
Thanks, your piece of code works, I do get the "nee" printed with that (after adding an extra ' behind 'post).
You helped my solve that problem. Only the question remains why with rc 5.5 the default behaviour changed, i.e. why is {fieldname} returned by default instead of an empty value when the checkbox isn't checked. It would be nice if that default behaviour would still work.
Hi mart1jn,
I didn't even know there was 5.5 release until I read your post, so I've no idea what has changed. As I said I don't know where the <empty> came from in the older version either.
Bob
PS Fixed the missing ', sorry.
I didn't even know there was 5.5 release until I read your post, so I've no idea what has changed. As I said I don't know where the <empty> came from in the older version either.
Bob
PS Fixed the missing ', sorry.
Hi mart1jn,
I agree, please contact me through the contact us page to get a fixed file!
Regards
Max
I agree, please contact me through the contact us page to get a fixed file!
Regards
Max
Hi Greyhead,
Sorry I probably haven't been very clear about what I meant with <empty>. In previous versions, when leaving the checkbox unchecked, the mail message would leave the value empty. I tried to designate that with <empty> but i might also have brought it this way:
In the mail sent by chronoform this used to be printed as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag
I hope that clarifies.
Anyway your solution is what I was looking for, and admin sent me a fix for the issue, so now again an empty value is printed instead of {fieldname} when the checkbox wasn't checked.
So thanks very much to you and admin for the great help!
all the best,
mart1jn.
Sorry I probably haven't been very clear about what I meant with <empty>. In previous versions, when leaving the checkbox unchecked, the mail message would leave the value empty. I tried to designate that with <empty> but i might also have brought it this way:
In the mail sent by chronoform this used to be printed as follows:
if checkbox was selected: Opruimen donderdag ja
if checkbox wasn't selected: Opruimen donderdag
I hope that clarifies.
Anyway your solution is what I was looking for, and admin sent me a fix for the issue, so now again an empty value is printed instead of {fieldname} when the checkbox wasn't checked.
So thanks very much to you and admin for the great help!
all the best,
mart1jn.
When the checkbox wasn't checked in the email appeares {fieldname} instead of just "nothing".
<input type="checkbox" name="Musik" id="Musik" value="Ja" />
<input type="checkbox" name="Musik" id="Musik" value="Ja" />
Hi saber,
An unchecked checkbox doesn't return any value from the form so there is nothing for hronoForms to replace the {filedname} with.
Use this code in the OnSubmit Before box:
Bob
Later: removed a stray comma
An unchecked checkbox doesn't return any value from the form so there is nothing for hronoForms to replace the {filedname} with.
Use this code in the OnSubmit Before box:
<?php
$Musik = JRequest::getString('Musik', 'Nein', 'post');
JRequest::setVar('Musik', $Musik);
?>
Bob
Later: removed a stray comma
Hi saber,
There was an extra , in this line:
Bob
There was an extra , in this line:
$Musik = JRequest::getString('Musik', 'Nein', ,'post');
it should be$Musik = JRequest::getString('Musik', 'Nein', 'post');
Bob
This topic is locked and no more replies can be posted.