php - How to populate input fields with post data when validation fails codeigniter
Get the solution ↓↓↓Solution:
Yes you can follow the link mentioned in the comments above and can set values usingset_value();
e.g. -
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
However I had noticed that it would set values for the fields which were being validated only so I had copied and customised the set_value to my own helper function e.g.
function set_value_myappname($field = '', $default = '', $fieldtype='text') {
if($fieldtype == 'text') {
if ( ! isset($_POST[$field]))
{
return $default;
}
return form_prep($_POST[$field], $field);
}
}
please note I did that with an older version of CI. The current 3.0 might have already something else in place for this sort of behaviour.
Hope that helps.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: an exception occurred in the driver: could not find driver
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.