Question

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 ?

Était-ce utile?

La solution

Textarea doesn't have a value attribute.

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top