CodeIgniter Forums
repopulating a 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: repopulating a textarea (/showthread.php?tid=18371)

Pages: 1 2


repopulating a textarea - El Forum - 05-04-2009

[eluser]junaids[/eluser]
i have a text area in my form. how do i repopulate it if validation fails. like we use
Code:
value="<?php echo $this->validation->location;?>"

for input field. but there is no "value" attribute for textarea. any idea?


repopulating a textarea - El Forum - 05-04-2009

[eluser]Dam1an[/eluser]
With a textarea, you do
Code:
<textarea name="my_textarea">
Contents of my textarea
</textarea>



repopulating a textarea - El Forum - 05-04-2009

[eluser]junaids[/eluser]
i dont understand
i have textarea like this
Code:
<textarea cols="16" rows="3" name="description" value="<?php echo $this->validation->description;?>"></textarea>

value attribute is used with input element to repopulate if form is not validated. but what to do with textarea. it has no value attribute. so tis not working i.e the textarea is not repopulated if validation is false


repopulating a textarea - El Forum - 05-04-2009

[eluser]Dam1an[/eluser]
try
Code:
<textarea cols="16" rows="3" name="description"><?php echo $this->validation->description;?></textarea>



repopulating a textarea - El Forum - 05-04-2009

[eluser]junaids[/eluser]
thanks
it works


repopulating a textarea - El Forum - 05-13-2009

[eluser]maicobreako[/eluser]
That exact solution didn't work for me, but this did.
Code:
<textarea name="comment" rows="7" cols="27"><?php echo $this->form_validation->set_value('comment');?></textarea>



repopulating a textarea - El Forum - 05-13-2009

[eluser]Dam1an[/eluser]
@maicobreako: there's also a shorthand version
Code:
// Long way
<textarea name="comment" class="inputs" rows="7" cols="27"><?php echo this->form_validation->set_value('comment');?></textarea>

// Short hand
<textarea name="comment" class="inputs" rows="7" cols="27"><?=set_value('comment')?></textarea>

set_value is a helper function, so it makes it a little bit less clittered


repopulating a textarea - El Forum - 05-13-2009

[eluser]maicobreako[/eluser]
Thanks for that, I'll try it out right now!


repopulating a textarea - El Forum - 05-13-2009

[eluser]maicobreako[/eluser]
Now don't I just feel special. On the line right above my textarea....
Code:
<input type="text" name="email" size="30" value="<?php echo set_value('email');?>" />

Well, uh....my computer has been acting strangely lately and I've been rather distracted...uh...well...uh... That's my story and I'm stickin' to it, I don't care whatch ya say!


repopulating a textarea - El Forum - 03-16-2010

[eluser]elaniobro[/eluser]
How would you post the textarea of your form back to the controller?