CodeIgniter Forums
How do you add a class to a 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: How do you add a class to a form dropdown? (/showthread.php?tid=33407)



How do you add a class to a form dropdown? - El Forum - 08-25-2010

[eluser]Wonder Woman[/eluser]
I have a dropdown with lots of options but was just wondering how I add a class to it?

Code:
$property_type = array(
   '0' => 'Any',
   '1' => 'Flats / Apartments',
   '2' => 'Terraced',
   '3' => 'Semi-detatched',
   '4' => 'Detatched',
   '5' => 'All Houses'
);

How do I put:

Code:
class => 'property'


into:

Code:
form_label('Property Type:', 'property_type').' '.form_dropdown('property_type', $property_type);

Thanks


How do you add a class to a form dropdown? - El Forum - 08-25-2010

[eluser]Maglok[/eluser]
http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

4th parameter. Wink Just create it kinda like this:

Code:
form_dropdown('name', $options, 'default', 'class="property"');

Though your question could also mean you want to add a class to the options of the dropdown, in which case I have no idea. Tongue


How do you add a class to a form dropdown? - El Forum - 08-25-2010

[eluser]Wonder Woman[/eluser]
That's exactly what I was after! Brilliant, thank you! Smile