My form field looks like this
echo form_label('Quantity', 'quantity');
echo form_input('quantity', $quantityx);
I modified it to retain form values
echo form_label('Quantity', 'quantity');
echo form_input('quantity', $this->input->post('quantity'));
I set the $quantityx above in the code behind in order to populate a value from the database so a user can edit a row.
How can I retain the value for validations, and have a variable to populate from the database at the same time?
I have tried this a well
echo form_label('Quantity', 'quantity');
echo form_input('quantity', set_value($quantityx));
Thanks for any suggestions
You can set them like this, if
set_value('columnanme')returnsfalsethen a form$_POSTdid not take place so what it will do is get the data from the data base example$profile->firstnameUse it like:
in your case you can do:
ANd on your form:
Assuming that
$quantityxholds the data from your databseEDIT
=============================================
Just use
set_values()second parameter as the default value. i.eset_value('name_of_input_field',$data_from_databse_as_default);If this does not work, then use my first answer.