Welcome Guest, Not a member yet? Register   Sign In
multiple dropdown
#1

[eluser]Seppo[/eluser]
In the new form_dropdown function, I like autodetecting for multiple dropdowns... but it has a problem, when I declare the multiple
Code:
echo (form_dropdown('a', array('a', 'b', 'c'), array('a','b'), 'multiple="multiple"'));

I´m getting
Code:
<select name="a" multiple="multiple" multiple="multiple"> <option value="0">a</option> <option value="1">b</option> <option value="2">c</option> </select>
(please note the multiple twice)

But if I don´t declare the multiple, it might have only one (or none) checked option, if multiple are allowed...

By the way, Derek, you left a ")" when you fixed the bug in this function, yesterday =)

Edit: I found a stupid typo, not worthy for a thread in string_helper, line 59, stering => string
#2

[eluser]barbazul[/eluser]
I don't thik that autodetecting multiple selects is always desired... thought i understand why it was implemented.
I think it would be great if there was a way to force a simple select regarding of the selected options array
#3

[eluser]Seppo[/eluser]
I think is better to create a new function to handle this... the multiple select are not actully "dropdown"...
Also, I still believe this feature is bug-friendly Tongue
I'm also thinking if there is a way to get all selected values without finishing the name with []...

So my suggestion is
Code:
function form_multiple($name = '', $options = array(), $selected = array(), $extra = '')
{
    if (strpos($name, '[]') === FALSE)
    {
        $name .= '[]';
    }
    $extra .= ' multiple="multiple"';
    return form_dropdown($name, $options, $selected, $extra);
}
#4

[eluser]Bharani[/eluser]
hi iwant to add the combo into the form..
tell me how can i do..
also i want to populate the values into that combo...

tell how i do that




Theme © iAndrew 2016 - Forum software by © MyBB