We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42701
    • 47 Posts
    I've got my FormIt template and code up and running. Everything works fine (error handling, email submission, etc.), except for the select box. When an error occurs in the form, FormItIsSelected doesn't select anything. Here's the code:

    <select name="num_bedrooms" value="[[!+fi.num_bedrooms]]">
    	<!--<option disabled selected>Desired Apartment Size</option>-->
    	<option value="">Desired Apartment Size</option>
    	<option value="one" [[!+fi.num_bedrooms:FormItIsSelected=`one`]]>One Bedroom</option>
    	<option value="two" [[!+fi.num_bedrooms:FormItIsSelected=`two`]]>Two Bedrooms</option>
    	<option value="three" [[!+fi.num_bedrooms:FormItIsSelected=`three`]]>Three Bedrooms</option>				
    </select>


    and the FormIt Snippet:

    [[!FormIt?
    	&hooks=`spam,email,redirect`
    	&emailTpl=`contactEmailTpl`
    	&emailTo=`[email protected]`
    	&redirectTo=`8`
    	&validate=`spam1:required,
    	  spam2:required,
    	  email:email:required`
    ]]


    Does anyone know what's wrong? Thanks.
      • 44437
      • 74 Posts
      Hey, try this

      <select name="num_bedrooms" value="[[!+fi.num_bedrooms]]">
          <!--<option disabled selected>Desired Apartment Size</option>-->
          <option value="">Desired Apartment Size</option>
          <option value="one" [[!+fi.num_bedrooms:is=`one`:then=`selected`]]>One Bedroom</option>
          <option value="two" [[!+fi.num_bedrooms:is=`two`:then=`selected`]]>Two Bedrooms</option>
          <option value="three" [[!+fi.num_bedrooms:is=`three`:then=`selected`]]>Three Bedrooms</option>                
      </select>
        • 42701
        • 47 Posts
        Tried this, unfortunately doesn't work either :\

        Quote from: random_noob at Jun 30, 2014, 06:18 PM
        Hey, try this

        <select name="num_bedrooms" value="[[!+fi.num_bedrooms]]">
            <!--<option disabled selected>Desired Apartment Size</option>-->
            <option value="">Desired Apartment Size</option>
            <option value="one" [[!+fi.num_bedrooms:is="`one`:then=`selected`]]">One Bedroom</option>
            <option value="two" [[!+fi.num_bedrooms:is="`two`:then=`selected`]]">Two Bedrooms</option>
            <option value="three" [[!+fi.num_bedrooms:is="`three`:then=`selected`]]">Three Bedrooms</option>                
        </select>
          • 44437
          • 74 Posts
          Quote from: zcmodxuser at Jun 30, 2014, 06:35 PM
          Tried this, unfortunately doesn't work either :\

          Quote from: random_noob at Jun 30, 2014, 06:18 PM
          Hey, try this

          <select name="num_bedrooms" value="[[!+fi.num_bedrooms]]">
              <!--<option disabled selected>Desired Apartment Size</option>-->
              <option value="">Desired Apartment Size</option>
              <option value="one" [[!+fi.num_bedrooms:is="`one`:then=`selected`]]">One Bedroom</option>
              <option value="two" [[!+fi.num_bedrooms:is="`two`:then=`selected`]]">Two Bedrooms</option>
              <option value="three" [[!+fi.num_bedrooms:is="`three`:then=`selected`]]">Three Bedrooms</option>                
          </select>

          I'm sorry, I am now seeing some errors.

          This
          <select name="num_bedrooms" value="[[!+fi.num_bedrooms]]">
          is incorrect.

          It should be like
          <select name="num_bedrooms" > 


          Full Code

          <select name="num_bedrooms">
              <option value="" disabled selected>Desired Apartment Size</option>
              <option value="one" [[!+fi.num_bedrooms:is=`one`:then=`selected`]]">One Bedroom</option>
              <option value="two" [[!+fi.num_bedrooms:is=`two`:then=`selected`]]">Two Bedrooms</option>
              <option value="three" [[!+fi.num_bedrooms:is=`three`:then=`selected`]]">Three Bedrooms</option>                
          </select>
          


          Hopefully I got it right this time around but it should work.
            • 42701
            • 47 Posts
            Thanks for the update, but still no go sad
              • 44437
              • 74 Posts
              i'm seeing additional quotes in the code
              <select name="num_bedrooms">
                  <option value="" disabled selected>Desired Apartment Size</option>
                  <option value="one" [[!+fi.num_bedrooms:is=`one`:then=`selected`]] >One Bedroom</option>
                  <option value="two" [[!+fi.num_bedrooms:is=`two`:then=`selected`]] >Two Bedrooms</option>
                  <option value="three" [[!+fi.num_bedrooms:is=`three`:then=`selected`]] >Three Bedrooms</option>                
              </select>
              


              This should do it
                • 42701
                • 47 Posts
                Still doesn't work. Is this a problem with FormIt? I'm using version 2.2.0.

                Quote from: random_noob at Jun 30, 2014, 11:42 PM
                i'm seeing additional quotes in the code
                <select name="num_bedrooms">
                    <option value="" disabled="" selected="">Desired Apartment Size</option>
                    <option value="one" [[!+fi.num_bedrooms:is="`one`:then=`selected`]]">One Bedroom</option>
                    <option value="two" [[!+fi.num_bedrooms:is="`two`:then=`selected`]]">Two Bedrooms</option>
                    <option value="three" [[!+fi.num_bedrooms:is="`three`:then=`selected`]]">Three Bedrooms</option>                
                </select>
                


                This should do it

                P.S. When I add value="[[!+fi.num_bedrooms]] to the select tag it comes up with the selected option value. Weird!
                  • 44437
                  • 74 Posts
                  That code has additional quotation marks. That's why it is not working. Please use code below.
                  <select name="num_bedrooms">
                      <option value="" disabled selected>Desired Apartment Size</option>
                      <option value="one" [[!+fi.num_bedrooms:is=`one`:then=`selected`]] >One Bedroom</option>
                      <option value="two" [[!+fi.num_bedrooms:is=`two`:then=`selected`]] >Two Bedrooms</option>
                      <option value="three" [[!+fi.num_bedrooms:is=`three`:then=`selected`]] >Three Bedrooms</option>                
                  </select>
                  


                  Modx has its own built in operators. That is what I'm using. Just tested it and it works.
                    • 42701
                    • 47 Posts
                    Still no dice. I'm chalking it up to a FormIt bug. I've encountered a couple others in this latest version. Thanks anyway for your help!
                      • 25195
                      • 9 Posts
                      Hi

                      There is a bug in the FormItIsSelected and FormItIsChecked snippets see tracker http://bugs.modx.com/issues/9876 and the changed code can be seen here for FormItIsChecked on github https://github.com/splittingred/FormIt/pull/82/files applying the same change to FormItIsSelected will fix that too.

                      Regards
                      Keith