-
- 659 Posts
Hi Lance,
Yes there’s another way, write a snippet which check the post value of the checkbox and disply it checked or unchecked...
I did it this way and it works fine...
Hope this helps
-
- 4,149 Posts
Add a hidden input tag with the same name as the checkbox and an empty value *before* your checkbox input tag.
This ensures the checkbox value is always sent.
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
-
- 57 Posts
thanks for the replies, i’ll try that.
-
- 49 Posts
Shaun,
I too have an issue with checkboxes in Formit. On my form I have a group of 6 checkboxes under the name "InterestedIn" when I try and out [[+InterestedIn]] on the email template chunk - nothing gets sent through.
Will I need to iterate through them in a snippet like this then call the snippet in the email template ?
Snippet to Iterate through check boxes:
$interest = $_POST[’InterestedIn’];
foreach( $interest as $interest => $output){
echo "<p>$output</p>";
And would it be better to somehow make this a function that could take a parameter for re-use purposes ?
-
- 4,149 Posts
Hm, interesting, i’ll look into it.
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
-
- 68 Posts
Hi Shaun,
I'm also interested in the ideal method of reading values into the email from checkboxes in the form.
Your idea of "Add a hidden input tag with the same name as the checkbox and an empty value *before* your checkbox input tag." is an interesting one but is this still required / preferred?
What happens with me at the moment is that I'll use something like this "[[+lamination:if=``:eq=`1`:then=`Yes`:else=`No`]]" (Thanks for sample mmuller) which works great if someone actually ticks the box. But if they dont tick the box the placeholder doesnt seem to get set at all and you actually see "[[+lamination:if=``:eq=`1`:then=`Yes`:else=`No`]]" appear in the email in its raw form.
The documentation needs updating in the formit RTFM perhaps to show such examples. Does the RTFM area of modx allow for contributed comments? I wouldnt mind adding bits and pieces to it as I work out the correct way to do things.
Also considering writing a formitwrapper package to make the generation of the forms and commands a little simpler.
Would love to know your thoughts.
-
- 91 Posts
Hey guys i know this is an old thread here but never know, someone could be looking.
I am using checkboxes and have follwed the documentation to get them working but in my email tpl where i have put the placeholder when i recieve the email it just outputs the placeholder.
Any ideas?
Twitter @alexmercenary