Search code examples
codeigniterselectdrop-down-menucodeigniter-form-helper

adding class and id in form_dropdown


Is there any possible way of adding class and id attributes in form_dropdown of CodeIgniter? I tried form_dropdown('name',$array,'class','id') and it's not changing anything, please tell me how to implement it?

Edited:
with my dropdown form like this form_dropdown('name',$array,set_value('someValue'),'id="myId"'); if I see my source from my browser it's look like this <select name="provinsi" id="provinsi_id">, but if I write like your way form_dropdown('name',$array,set_value('someValue'),'class="myClass"','id="myId"'); than like this in my browser source <select name="provinsi" class="myClass">

that was I mean
thank you


Solution

  • Like this:

    form_dropdown('name', $array, '', 'class="my_class" id="my_id"')
    

    The third parameter is for the value you wish to be selected and the fourth is for the additional data. Read more.