We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8830
    • 98 Posts
    Hi,

    I'm making a pretty simple FormIt hook to send some data to a web service.

    I can get all values using:
    $allFormFields = $hook->getValues();


    and then using:
    $allFormFields['formFirstName']

    to get the value.

    My radio button HTML looks like this:
    <input type="radio" name="formGender[]" value="male" class="required" [[!+fi.formGender:FormItIsChecked=`male`]] > Male
    <input type="radio" name="formGender[]" value="female" [[!+fi.formGender:FormItIsChecked=`female`]] > Female


    But when I fetch the data like this:
    $allFormFields['formGender']

    I get an "Array".

    How do I get the actual data to see if the male radio button is checked?

    I'm using MODx 2.1.2 for this project.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Radio buttons should not be arrays; get rid of the [] in the name. Those are only needed for checkboxes, where it's possible there could be multiple selections.
        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
        • 8830
        • 98 Posts
        That solved my problem. Thank you.