1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Select Multiple Forms in XenForo?

Discussion in 'XenForo Development Discussions' started by Jaxel, Nov 26, 2010.

  1. Jaxel

    Jaxel Well-Known Member

    using XenForo_Input::ARRAY_SIMPLE works great for pretty much every type of input array. The problem is that it can't handle select multiple forms. How should I be handling these?

    I just want to take all the results and put it in a comma delimited string.
     
  2. Shadab

    Shadab Well-Known Member

    Not sure what you mean by "multiple forms" (as you can submit only one form at a time). Are you looking for a way to filter the values inside an array that you have already filtered via XenForo_Input::ARRAY_SIMPLE ?
     
  3. Jaxel

    Jaxel Well-Known Member

    I'm talking about <select multiple>
     
  4. Shadab

    Shadab Well-Known Member

    I tested this and it worked just fine:

    HTML:
    <form action="test.php" method="post">
    	<select name="sel1[]" multiple="multiple">
    		<option value="Value1">Value 1</option>
    		<option value="Value2">Value 2</option>
    		<option value="Value3">Value 3</option>
    	</select>
    	<input type="submit" />
    </form>
    PHP:
    $request = new Zend_Controller_Request_Http();
    $input = new XenForo_Input($request);

    $formInput $input->filterSingle('sel1'XenForo_Input::ARRAY_SIMPLE);

    Zend_Debug::dump($formInput);
    Code:
    array(2) {
      [0] => string(6) "Value2"
      [1] => string(6) "Value3"
    }
     
  5. Mike

    Mike XenForo Developer Staff Member

    I'd guess that you're not naming the input correctly - it needs the "[]" at the end. This is PHP stuff though, not XF. PHP will only see one value from the list if submitted without the square brackets.
     
  6. Mythotical

    Mythotical Well-Known Member

    Ahhhh this explains a lot. Thanks for this thread. I left off the []
     
  7. Jaxel

    Jaxel Well-Known Member

    Yep, that was the issue... thanks.
     

Share This Page