How Do I Set A Maxlength For Codeigniters Form_textarea()?
I am trying to set a maxlength for the form_textarea() in Codeigniter. I tried the following: '100' ); ?><
Solution 1:
Codeigniter allows you to pass attributes into your form elements by way of an associative array.
Documentation for the form helper is here: http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html
Although I can see exactly what you're trying to do, there's one caveat with textareas. From the documentation:
form_textarea()
This function is identical in all respects to the form_input() function above except that it generates a "textarea" type. Note: Instead of the "maxlength" and "size" attributes in the above example, you will instead specify "rows" and "cols".
So, you need to pass rows and columns instead of maxlength for textareas. Your code would look something like this:
$options = array(
'rows' => 10,
'cols' => 10
);
Solution 2:
form_textarea(array(
'cols' => 1,
'rows' => 1
));
Post a Comment for "How Do I Set A Maxlength For Codeigniters Form_textarea()?"