Repopulate TextArea |
[eluser]RobbieL[/eluser]
I'm having a bit of trouble with textareas in my forms not repopulating. The $field for them is there in my controller. All text inputs in the form work fine, just not textareas. Here the code in my view; Code: <textarea name="description" "value="<?=$this->validation->description;?>"></textarea><?=$this->validation->description_error; ?> Looked through the CI's userguide on Validation, and can't spot anything about textareas. Anyone got anyideas on what's going on?
[eluser]ballen[/eluser]
I don't think you use "value" for text areas..at any rate that quote before it probably doesn't help I would try this: Code: <textarea name="description"><?=$this->validation->description;?></textarea><?=$this->validation->description_error; ?>
[eluser]phester[/eluser]
Just to add, The only time you can use the "value" attribute is with textareas to pass in data is with the form helper Code: form_textarea(array('name' => 'field_name_here', 'value' => $this->validation->field_name_here)); The helper will in turn output the correct HTML as ballen showed in the previous post.
[eluser]jahboite[/eluser]
But what about if you want a text area to be shown with an initial value, such as "Type something here"?
[eluser]Michael Wales[/eluser]
Code: <textarea>Type something here</textarea> If you use the form helper: Code: form_textarea(array('name' => 'field_name_here', 'value' => 'Type something here'));
[eluser]jahboite[/eluser]
Yeah, sorry, I meant (using the form helper) show an initial value and use form validation to repopulate the textarea if it validates incorrectly.
[eluser]Michael Wales[/eluser]
Code: if ($this->validation->field_name) {
[eluser]jahboite[/eluser]
You beauty! That's so bloody simple and I struggled so hard. Thank you. I'm having an issue with form validation on my hosted server, it's all fine on my local one: http://ellislab.com/forums/viewthread/63234/ |
Welcome Guest, Not a member yet? Register Sign In |