Select Multiple Forms in XenForo?

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.
 
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 ?
 
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"
}
 
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.
 
Top Bottom