CodeIgniter, form helper - Adding classes to the elements
12,032
$data = array(
'name' => 'title',
'value' => $this->input->post('title'),
'class' => 'titleInput',
'style' => 'height:30px'
);
echo form_input($data);
Author by
Kevinvhengst
Updated on June 14, 2022Comments
-
Kevinvhengst almost 2 years
So i created a form with the CodeIgniter Form helper. I'm trying to give some form elements a class, but something strange happens. I do it like this:
echo form_input('title', $this->input->post('title'), 'class="titleInput"');
When i inspect the element it actually shows the class is there:
but it doesn't take any of the property's given in the CSS file. Also when i do something ugly like:
echo form_input('title', $this->input->post('title'), style="height=30px");
When i inspect the element i get this:
But it doesn't actually do anything with the styling given.
Hopefully someone can give me a hand here!
-
Kevinvhengst over 10 yearsThx! I've read the docs as well, but thought my approach was going to work aswell, since i actually saw the classes and styling while inspecting the element. On a side note, you should edit and add a comma after the
value
and remove the one behindstyle
:) Thx for your help mate! -
spreaderman over 7 yearsHow would you add 'disabled' to the above? There is no identifier, just 'disabled'