CodeIgniter Forums
Form validation: re-populate empty field - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forum-11.html)
+--- Thread: Form validation: re-populate empty field (/thread-1476.html)



Form validation: re-populate empty field - Stradge - 03-13-2015

English isn’t my first language, so please excuse any mistakes.

This is my input field:

Code:
<input type="text" name="title" id="title" value="<?php echo set_value('title', $venue['title']) ?>" autocomplete="off" />

According to my validation rules this field is required. After submitting the form with an empty "title" the form is showing the default value of "$venue['title']". I was expecting (and hoping) to see an empty input field. Otherwise the displayed error message (saying this field is required) seems a bit confusing.

It's working (=showing blank field) in CI2 with almost identical code.

Did I miss something?

THX in advance


RE: Form validation: re-populate empty field - ivantcholakov - 03-13-2015

@Stradge

I also noticed this behavior, and I think in this case (while a previously non-empty field is edited and 'required' rule fails) an empty field should be shown. IMO you are correct.


RE: Form validation: re-populate empty field - ivantcholakov - 03-13-2015

This should be checked for check-boxes too. There is a "hidden" rule 'isset'.