• 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?

Jaxel

Well-known member
#1
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.
 

Shadab

Well-known member
#2
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 ?
 

Shadab

Well-known member
#4
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"
}
 

Mike

XenForo developer
Staff member
#5
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.