Welcome Guest, Not a member yet? Register   Sign In
repopulating a textarea
#1

[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?
#2

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

[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
#4

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

[eluser]junaids[/eluser]
thanks
it works
#6

[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>
#7

[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
#8

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

[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!
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB