Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Repopulate a form field without setting rule as required in Codeigniter?

When I try to populate a form field which is not required in form validation doesn't repopulate. Let's say I have a field but I don't want it to be required but I want it to be repopulated. How can I do it ? I think this is a bug for codeigniter.

like image 724
SNaRe Avatar asked Feb 22 '23 09:02

SNaRe


1 Answers

This piece of code solved my problem. But I have to use helpers for that. At least I have a solution.

function value_field($field, $default='') {
    return (isset($_POST[$field])) ? $_POST[$field] : $default;
} 
like image 81
SNaRe Avatar answered Apr 28 '23 05:04

SNaRe