CodeIgniter Forums
id in form_dropdown() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: id in form_dropdown() (/showthread.php?tid=12228)



id in form_dropdown() - El Forum - 10-10-2008

[eluser]Mitja B.[/eluser]
Code:
form_dropdown('categoryId', $options)

is it possible to use id in form_dropdown() like
<select name="select1" id="select1">

or just name="".


id in form_dropdown() - El Forum - 10-10-2008

[eluser]Derek Allard[/eluser]
You could add id through the 4th parameter.
Code:
echo form_dropdown('categoryId', $options, 'default', 'id="categoryId");



id in form_dropdown() - El Forum - 10-10-2008

[eluser]Pascal Kriete[/eluser]
[Edit: Ignore this, beat by the robot - need to learn to refresh]

You can, just pass a string of additional parameters to the function as it's 4th parameter.
Code:
echo form_dropdown('shirts', $options, 'large', 'id = "select1"');
What you can't have is an individual id on each option, you would need to extend the helper to achieve that.


id in form_dropdown() - El Forum - 10-10-2008

[eluser]Mitja B.[/eluser]
Thx for fast reply.

What about to add first parameter of option like <option value="">Select</option>. is this possible to add?


id in form_dropdown() - El Forum - 10-10-2008

[eluser]Derek Allard[/eluser]
If you're trying to add an id to an <option>, then as Inparo said, that's not possible without modifying the helper.