开发者

CodeIgniter - form_dropdown defaults to multiple

开发者 https://www.devze.com 2023-02-19 07:59 出处:网络
Im having a little trouble with my form_dropdown in codeigniter, basically it ALWAYS adds the multiple=\"multiple\" and i dont know how to get rid of it.

Im having a little trouble with my form_dropdown in codeigniter, basically it ALWAYS adds the multiple="multiple" and i dont know how to get rid of it.

Here is the开发者_如何学Go code im using to generate the dropdown

$js = 'class="users"';
echo form_dropdown('users', $users, set_value('users', $users), $js);

Is there anything i can add so that it doesnt automatically create it with the multiple option


I think the issue is related to your third option set_value('users',$users)

Since $users is probably an array, the set_value may be setting multiple options to selected and in such a case form_dropdown would generate the multiple property.

Try passing a single user value and make sure that works as you expect.

Also, check the out put from the set_value function to see if it returns an array instead of a single value.


You don't need to use set_value here. Just use the value you want selected.

$js = 'class="users"';
$user = 1;
echo form_dropdown('users', $users, $user, $js);
0

精彩评论

暂无评论...
验证码 换一张
取 消