2

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:

enter image description here

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:

enter image description here

But it doesn't actually do anything with the styling given.

Hopefully someone can give me a hand here!

1 Answer 1

7
$data = array(
          'name'        => 'title',
          'value'          => $this->input->post('title'),
          'class'       => 'titleInput',
          'style'       => 'height:30px'
        );

echo form_input($data);

reference

Sign up to request clarification or add additional context in comments.

2 Comments

Thx! 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 behind style :) Thx for your help mate!
How would you add 'disabled' to the above? There is no identifier, just 'disabled'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.