We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37042
    • 384 Posts
    I'm making an Event Registration form for someone and we have a series of checkboxes for the events.

    Client has requested a way of updating the checkbox values via the MODX Manager and I was wondering what the best approach would be?

    In the default checkbox example below, I know I could achieve it with some TVs by making a TV for each color.


    [[!FormIt? &validate=`color:required`]]
    <label>Color: [[!+fi.error.color]]</label>
    <input type="hidden" name="color[]" value="" />
    <input type="checkbox" name="color[]" value="blue" [[!+fi.color:FormItIsChecked=`blue`]] > Blue 
    <input type="checkbox" name="color[]" value="red" [[!+fi.color:FormItIsChecked=`red`]] > Red 
    <input type="checkbox" name="color[]" value="green" [[!+fi.color:FormItIsChecked=`green`]] > Green 



    Would change to...


    [[!FormIt? &validate=`color:required`]]
    <label>Color: [[!+fi.error.color]]</label>
    <input type="hidden" name="color[]" value="" />
    <input type="checkbox" name="color[]" value="[[*tv1]]" [[!+fi.color:FormItIsChecked=`[[*tv1]]`]] > [[*tv1]] 
    <input type="checkbox" name="color[]" value="[[*tv2]]" [[!+fi.color:FormItIsChecked=`[[*tv2]]`]] > [[*tv2]]
    <input type="checkbox" name="color[]" value="[[*tv3]]" [[!+fi.color:FormItIsChecked=`[[*tv3]]`]] > [[*tv3]]
    



    My issue with this approach is the client has a changeable number of events and I would always have to know in advance to setup appropriate TVs for her.

    I know someone may mention MIGX but I was hoping for an alternative :-/

    This question has been answered by sottwell. See the first response.

    [ed. note: eladnova last edited this post 10 years, 5 months ago.]
      ...
    • discuss.answer
      Why hoping for an alternative? MIGx would be perfect for generating the entire set of checkboxes. This would be a very simple application of MIGx, too. Just copy/paste the basic sample from the rtfm, and remove all the fields you don't need from the form and the grid. The tpl of the output snippet getImageList would be something like
      <input type="checkbox" name="color[]" value="[[+color]]" [[!+fi.color:FormItIsChecked=`[[+color]`]] > [[+color]]

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 37042
        • 384 Posts
        Ok I tried the solution using MIGX and it works very well smiley

        If anyone else is trying to do this in future, I used Formee.org (a web form framework) for my form

        <ul class="formee-list">
          [[getImageList? &tvname=`Event-Name` &tpl=`MIGX-Event-Names`]] 
        </ul>


        and my TPL looked like this

        <li>
        <input type="checkbox" name="event[]" value="[[+Event-Title]]" [[!+fi.color:FormItIsChecked=`[[+Event-Title]]`]] > [[+Event-Title]]
        </li>


          ...