Jun 18, 2010
Im using Codeigniter Form Validation class to validate some forms. The forms are used to store info on a db. Im using the following code, to load all the values into the fields:
View 3 Replies
<?php echo ($ae == 'edit') ? form_input('name',$records->name) : form_input('name', set_value('name')); ?>
So, if we are Editing the form, we load it with the value from the db. If we are Adding, we use the set_value() function to set the value in case that an error msg appeared.
This works ok. But I want to see if there's a better way of writting that line or doing this. For example, one of the problems of this approach is that, if im editing a form and after submitting it I get an error, I lose all the info I just modified, and the db info is restored. Not a big deal though.