CodeIgniter Forums
Dropdown helper default id property set - 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: Dropdown helper default id property set (/showthread.php?tid=10830)



Dropdown helper default id property set - El Forum - 08-14-2008

[eluser]Remko Posthuma[/eluser]
The dropdown helper does generate a name property but no id property by default. Is it an option to do this by default instead of using the extra? This will make the dropdownbox usable for JS in the page. I have modded line: 260 of form_helper.php to:
$form = '<select name="'.$name.'" id="'.$name.'"'.$extra.$multiple.">\n";


Dropdown helper default id property set - El Forum - 08-15-2008

[eluser]Derek Allard[/eluser]
Welcome to CodeIgniter Remko. This isn't a bug, its the intended use of the helper. The best bet for compatibility is to simply extend it out using your preferred method.


Dropdown helper default id property set - El Forum - 08-15-2008

[eluser]Colin Williams[/eluser]
Quote:If you would like the opening <select> to contain additional data, like JavaScript, you can pass it as a string in the fourth parameter

Code:
&lt;?= form_dropdown($name, $opts, NULL, 'id="'. $name .'"');