![]() |
Repopulate TextArea - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Repopulate TextArea (/showthread.php?tid=3714) |
Repopulate TextArea - El Forum - 10-18-2007 [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? Repopulate TextArea - El Forum - 10-18-2007 [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; ?> Repopulate TextArea - El Forum - 10-18-2007 [eluser]RobbieL[/eluser] Ballen, you're a lifesaver! Big thanks. ![]() Repopulate TextArea - El Forum - 10-18-2007 [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. Repopulate TextArea - El Forum - 10-21-2007 [eluser]jahboite[/eluser] But what about if you want a text area to be shown with an initial value, such as "Type something here"? Repopulate TextArea - El Forum - 10-21-2007 [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')); Repopulate TextArea - El Forum - 10-21-2007 [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. Repopulate TextArea - El Forum - 10-21-2007 [eluser]Michael Wales[/eluser] Code: if ($this->validation->field_name) { Repopulate TextArea - El Forum - 10-21-2007 [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/ |