We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21884
    • 57 Posts
    i’m using the latest version of FormIt, but having trouble. I tried an example i found on the forums of keeping checkboxes that were checked if the form returns validation errors, but it’s not working:

    <label class="interest_label" for="buying">Buying<input class="interest" id="buying" name="buying" value="Buying" type="checkbox" [[+fi.buying:notempty=`checked="checked"`]] /></label>


    seems like phx doesn’t work with FormIt, is there another way to go about this?
      • 1778
      • 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
        • 28215
        • 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
          • 21884
          • 57 Posts
          thanks for the replies, i’ll try that.
            • 19909
            • 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 ?
              • 28215
              • 4,149 Posts
              Hm, interesting, i’ll look into it.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 19909
                • 49 Posts
                Shaun,

                I think it might be me... however I found another of your insightful posts - which are almost as good as your blog posts for info wink

                and have resolved the issue with:

                [[+lamination:if=`[[+lamination]]`:eq=`1`:then=`Yes`:else=`No`]]

                For each item in the checkbox I have renamed as an individual element and parsed them separately. More work but it works laugh

                I don’t seem to get an error checking though... So I am looking into that sad

                Regards,

                Mark
                  • 21635
                  • 81 Posts
                  Quote from: mmuller at Jul 22, 2010, 12:24 PM

                  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 ?

                  i have a similar problem, i have checkboxes for multiple choice, but the placeholder only outputs the last checked item.


                  [[+lamination:if=`[[+lamination]]`:eq=`1`:then=`Yes`:else=`No`]]
                  


                  is this still a valid way of doing things?? i couldn’t find the expression in the documentation of output filters.

                  thanks
                    • 18270
                    • 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.
                      • 38713
                      • 91 Posts
                      alexmercenary Reply #10, 12 years ago
                      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