ranggadablues
ranggadablues

Reputation: 249

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

Upvotes: 11

Views: 29834

Answers (2)

Usman Ahmed
Usman Ahmed

Reputation: 2557

You can defined class, id or any other HTML attribute in the forth parameter of form_dropdown() function as an associative array like below:

form_dropdown('name', $array, set_value('someValue'), ['class' => 'myClass', 'id' => 'myId']);

Upvotes: 0

Yan Berk
Yan Berk

Reputation: 14428

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.

Upvotes: 35

Related Questions