We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33238
    • 388 Posts
    Hello Everyone.

    I have a question about how to do this:

    I have a form with FormIt, the form has a select field and a custom snippet to call it using a hook (CustomHook):

    in the snippet call:
        &hooks=`spam,email,FormItAutoResponder,CustomHook`
    

    in the form:
            			<label>Select Field:
            				 <select name="selectHere">
            					<option value="one" [[!+fi.selectHere:FormItIsSelected=`one`]]>Select One</option>
            					<option value="two" [[!+fi.selectHere:FormItIsSelected=`two`]]>Select Two</option>
            					<option value="three" [[!+fi.selectHere:FormItIsSelected=`three`]]>Select Three</option>
            				</select>
            			</label>


    But I need to run 3 different hooks, every one depending on the One, Two or Three option that the client decide to select.

    Option One = sibmit = run Custom Hook 1
    Option Two = sibmit = run Custom Hook 2
    Option Three = sibmit = run Custom Hook 3

    How can I do that? What is the right way?

    Thank you very much!!!

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

      --
      ysanmiguel.com
      • 19872
      • 1,078 Posts
      Hey Yanni!
      Here is how I set up my select menu for a form. I don't have any custom hook associated with it. For my hooks, I just have the typical spam, email, redirect

      <div class="large-4 columns">
            <label>I want to advertise on:
              <select name="pubDate1" value="[[!+fi.pubDate1]]">
                <option value="">Choose Date</option>
      	  <option value="December 5" [[!+fi.pubDate1:is=`December 5`:then=`selected`]]>December 5 · Materials Due 11/27</option>
      	  <option value="December 12" [[!+fi.pubDate1:is=`December 12`:then=`selected`]]>December 12 · Materials Due 12/4</option>
      	  <option value="December 19" [[!+fi.pubDate1:is=`December 19`:then=`selected`]]>December 19 · Materials Due 12/11</option>
      
              </select>
            </label>
      </div>
      • discuss.answer
        • 4172
        • 5,888 Posts
        can't you switch inside your hook depending on the option?

        $selectHere = $hook->getValue('selectHere');
        
        switch ($selectHere){
            case 'one':
                //do one
            break;
            case 'two':
                //do two
            break;
            case 'three':
                //do three
            break;
        }
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 33238
          • 388 Posts
          Bruno I will try that, I'm just not sure if FormIt has "something" to do that kind of things. Or what was the best way to do it.

          Thank you very much!
            --
            ysanmiguel.com
            • 33238
            • 388 Posts
            Looks Like works, Thank you Bruno!!! smiley
              --
              ysanmiguel.com
              • 33238
              • 388 Posts
              Looks Like works, Thank you Bruno!!! smiley
                --
                ysanmiguel.com