[eluser]paul-s-[/eluser]
I am trying to add attributes to the element only by defining an array as per the user guide. The attributes are getting added to the element as expected but some of the attributes in the array are also getting added to the label.
e.g. using a little test date the controller is:
Code:
$attributes=array('data-type'=>'toggle','class'=>'foo bar ','placeholder'=>'firstname','type'=>'email');
$this->form->text('email','Email','trim','',$attributes);
Which outputs the following HTML:
Code:
<label for="email" class="foo bar" data-type="toggle">Email</label>
<input type="text" name="email" value="" data-type="toggle" class="foo bar" placeholder="firstname" autocomplete="off" id="email" />
You can see that the "data-type" and "class" get added to the label - but the others don't and having the "class" applied to the label is causing layout issues.
Is there a way to apply the attributes only to the element as per the manual - what am I doing wrong?
== UPDATE ==
Sussed it. The manual is a little confusing (for me anyway) in that it says "supply a string or an associative array with attributes. However whiilst this didn't work
Code:
$attributes=array('data-type'=>'toggle','class'=>'foo bar ','placeholder'=>'firstname','type'=>'email');
a comma-separated STRING version does : "
Code:
.....,'class=foo bar, placeholder=firstname, data-type=toggle');