Welcome Guest, Not a member yet? Register   Sign In
form_multiselect 4th param issue
#1

[eluser]steveblair[/eluser]
When passing additional information to a form_multiselect in the fourth parameter, having the string "multiple" contained in the variable turns the multiple select input into a simple select input.

Code:
$params = 'id="multiple"';
echo form_multiselect($name, $options, $selected, $params);

It should output a select element with multiple="multiple", however the multiple attribute completely disappears whenever the string "multiple" is passed in the fourth parameter.
#2

[eluser]InsiteFX[/eluser]
Code:
$params = array('id' => 'multiple');
#3

[eluser]steveblair[/eluser]
Tried that and it throws an error from the form_helper

Quote:A PHP Error was encountered
Severity: Warning
Message: strpos() expects parameter 1 to be string, array given
Filename: helpers/form_helper.php
Line Number: 285

I've been referencing the form_helper page in the user guide, under form_dropdown, and they format the fourth parameter as I have.

It's not a huge deal for me, I simply assigned a different id, but it seems odd that the string "multiple" breaks the form_multiselect
#4

[eluser]CroNiX[/eluser]
Looking at the code for form_multiselect() you can easily see why:
Code:
if ( ! strpos($extra, 'multiple'))
{
  $extra .= ' multiple="multiple"';
}

It only adds multiple="multiple" if the word "multiple" is not found within the string of the 4th parameter.
#5

[eluser]steveblair[/eluser]
Well, I guess they have a reason for it, but seems like there'd be a more precise way of processing the data.

I actually wanted to add a title as tool-tip for the multiselect that read along the lines of "to select multiple options..." So, not a big deal to reword it, but wouldn't be surprised if others have run into the same problem.
#6

[eluser]CroNiX[/eluser]
Yes, it's a bit limiting in your one specific case. It seems you can use it but you'd have to explicitly set the multiple parameter as well.
Code:
$params = 'multiple="multiple" id="multiple"';
#7

[eluser]Aken[/eluser]
This is a small bug that could use some better implementation. Thanks for sharing.




Theme © iAndrew 2016 - Forum software by © MyBB