Textarea using set_value not populated Codeigniter
Asked Answered
B

2

8

i have a simple form in my view that has a text area :

<textarea name="description" value="<?php echo   set_value('description'); ?>"></textarea>

in my controller i have validated this text area using form_validation library

$this->form_validation->set_rules('description', 'Description', 'trim|required');

the validation is working perfectly , ie it gives me the error if text area is blank , but it does not repopulate the textarea , if textarea-description is correctly filled but there is some error in the other fields

What am i doing wrong ?

Bourgogne answered 16/8, 2012 at 11:1 Comment(0)
A
30

Textarea doesn't have a value attribute.

<textarea name="description"> 
      <?php echo set_value('description'); ?> 
</textarea>
Archway answered 16/8, 2012 at 11:3 Comment(5)
could i be more stupid ? thanks alot , that was quick and perfectBourgogne
Yes you can. It is the third paremeter if you are using the form helper.Archway
iam using <?php echo form_dropdown('mid', $id_map, '', 'id="_pro"') ?>Bourgogne
<?php echo form_dropdown('mid', $id_map, set_value('mid'), 'id="promotion_product"') ?>Archway
This is out of the scope of this question. Please ask a new question and post the code you tried and the errors you received.Archway
M
0

If value return only form_validation:

<?=form_textarea(array('name'=>'description'),set_value('description'));?>

If the value is elsewhere:

<?=form_textarea(array('name'=>'description'),set_value('description',$value));?>

Documentation CodeIgniter: https://www.codeigniter.com/user_guide/helpers/form_helper.html

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".

Mindimindless answered 15/5, 2016 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.