Form Validation / Pre-populated input fields |
[eluser]intoitdaily[/eluser]
turns out, I was right... CodeIgniter will not pre-populate your input fields when running form validation, <i>unless</i> you set a rule for that input field in the controller. However, what if there is a field that isn't required in your form, but you still want it to be pre-populated if an error is found elsewhere in the form? Here's the work-around... You have to add your own validation function in the form of a callback ( http://ellislab.com/codeigniter/user-gui...#callbacks ) So here's what I did. Controller Code: function auto() View (form) Code: <?= form_open(); ?> Notice, in the view I didn't add the print error for the non-required fields. This workaround worked for me. Let me know how it works for you guys. |
Messages In This Thread |
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 12:50 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 02:16 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 02:34 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 03:04 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 03:22 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 05:10 PM
Form Validation / Pre-populated input fields - by El Forum - 08-11-2009, 06:30 PM
Form Validation / Pre-populated input fields - by El Forum - 08-12-2009, 03:03 AM
Form Validation / Pre-populated input fields - by El Forum - 08-16-2009, 05:27 AM
Form Validation / Pre-populated input fields - by El Forum - 08-22-2009, 09:38 PM
|