We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16544
    • 86 Posts
    I created a form with FormIt and is working fine but I have no idea how to get the data of a Checkbox and Radios. E.g.
    I have a checkbox section called color so, when I get the email I get [[+color]]. I can't find any examples, even here: http://rtfm.modx.com/display/ADDON/FormIt.Examples.Simple+Contact+Page doesn't tell how to. Any help? Thanks.
      I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
      • 32316
      • 387 Posts
      questions for you:
      1 - What do you mean by get the data? Do you want it emailed to somewhere, or are you trying to do something with it?
      2 - What is missing between the get and the '.' in:
      I have a checkbox section called color so, when I get the email I get .
      3 - A bit of the code you are using might help.
      4 - The link you provide does give an examples of checkboxes and radios - and the next link at the bottom the page http://rtfm.modx.com/display/ADDON/FormIt.Handling+Selects%2C+Checkboxes+and+Radios gives some more information - that is unless you are trying to do something with the POST data from the form - this goes back to question 1.
        • 16544
        • 86 Posts
        OK, let's say you go to the website, fill up the form, e.g. name, email and phone number. When you submit it some one will get the name, email and phone number. So, if you have
        [[+name]]
        you'll will get 'the name'.

        Going back to http://rtfm.modx.com/display/ADDON/FormIt.Examples.Simple+Contact+Page you have a form with check boxes and radios but if you go to the bottom of the page, you'll see:

        MyEmailChunk (Tpl Chunk)
        This is the Formit Email Chunk. 
        
        [[+name]] ([[+email]]) Wrote: 
         
        [[+text]]

        With this you only get name, email and text. So, if I have a radio of red, blue and green what would be the tag to get the selected result?

        I have colors:required in my Snippet Tag. I have [[+color]] in my email chunk but it won't work.

        Thank for your response. [ed. note: labanino last edited this post 14 years, 10 months ago.]
          I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
          • 12028
          • 152 Posts
          I think you should do something like this in the code for your form:
          <p><strong>Preferred time of day? <span class="error">[[!+fi.error.appt_time]]</span></strong></p>
             <input type="hidden" name="appt_time[]" value="" />
             <input type="radio" name="appt_time[]" value="Morning" id="Morning" [[!+fi.appt_time:FormItIsChecked=`Morning`]] /> <label for="Morning">Morning</label>
             <input type="radio" name="appt_time[]" value="Evening" id="Evening" [[!+fi.appt_time:FormItIsChecked=`Evening`]] /> <label for="Evening">Evening</label>
             <input type="radio" name="appt_time[]" value="No preference" id="appt-time-No-preference" [[!+fi.appt_time:FormItIsChecked=`No preference`]] /> <label for="appt-time-No-preference">No preference</label> 
            - A small step for mankind, so why not take two...

            Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
            • 16544
            • 86 Posts
            Hi Henrik, thanks for the response. Maybe I'm wrong but I guess that:
            <p><strong>Preferred time of day? <span class="error">[[!+fi.error.appt_time]]</span></strong></p>
               <input type="hidden" name="appt_time[]" value="" />
               <input type="radio" name="appt_time[]" value="Morning" id="Morning" [[!+fi.appt_time:FormItIsChecked=`Morning`]] /> <label for="Morning">Morning</label>
               <input type="radio" name="appt_time[]" value="Evening" id="Evening" [[!+fi.appt_time:FormItIsChecked=`Evening`]] /> <label for="Evening">Evening</label>
               <input type="radio" name="appt_time[]" value="No preference" id="appt-time-No-preference" [[!+fi.appt_time:FormItIsChecked=`No preference`]] /> <label for="appt-time-No-preference">No preference</label>


            for it self does nothing. This is divided in two parts, 1 is the form itself and 2 the template chunk where all the values submitted will be displayed.
              I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
              • 12028
              • 152 Posts
              Just to clarify (sorry, I forgot to explain...):
              The above example are just a fragment of the form.
              The hidden
              appt_time[]
              value are receiving the value from the checked checkboxes.
              The
              [[!+fi.appt_time:FormItIsChecked=`Morning`]]
              are receiving the value of the checkbox if it is checked (And are making the checkbox checked if there are any validation errors on submit).

              And in the email chunk you can output all the checked values with:
              [[+appt_time]]


              I hope it helps!



                - A small step for mankind, so why not take two...

                Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
                • 16544
                • 86 Posts
                The form is working right, I get name, email and message, only
                [[+appt_time]]
                is causing problems, I get just that
                [[+appt_time]]
                . What am I doing wrong? This is not the complete form, just a portion of it. Thanks Henrik.

                [[!FormIt?
                  &hooks=`recaptcha,spam,email,redirect`
                  &emailTpl=`ContactFormReport`
                  &emailTo=`[[++emailsender]]`
                  &emailUseFieldForSubject=`1`
                  &redirectTo=`15`
                  &submitVar=`submitContact`
                  &validate=`name:required,
                      email:email:required,
                      appt_time:required,
                      message:required`
                ]]
                
                
                <p>Preferred time of day? <span class="error">[[!+fi.error.appt_time]]</span></p>
                <input type="hidden" name="appt_time[]" value="" />
                <input type="radio" name="appt_time[]" value="Morning" id="Morning" [[!+fi.appt_time:FormItIsChecked=`Morning`]] /><label for="Morning">Morning</label>
                <input type="radio" name="appt_time[]" value="Evening" id="Evening" [[!+fi.appt_time:FormItIsChecked=`Evening`]] /><label for="Evening">Evening</label>
                <input type="radio" name="appt_time[]" value="No preference" id="appt-time-No-preference" [[!+fi.appt_time:FormItIsChecked=`No preference`]] />
                <label for="appt-time-No-preference">No preference</label>
                
                
                <h2>My form result</h2>
                <p>[[+name]]</p>
                <p>[[+email]]</p>
                <p>[[+appt_time]]</p>
                <p>[[+datepicker]]</p>
                [ed. note: labanino last edited this post 14 years, 10 months ago.]
                  I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
                  • 12028
                  • 152 Posts
                  Could you place:
                  [[!FormItRetriever]]

                  - before your FormIt call, and try if that helps?
                    - A small step for mankind, so why not take two...

                    Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
                    • 16544
                    • 86 Posts
                    Done! I was testing FormIt with the MODx Sample Site 1.1.0-pl and it looks like the FormIt version shipped with it has some kind of problem. So, I just installed the latest version of FormIt and now everything is fine. Thanks.
                      I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.