Repopulating form fields - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Repopulating form fields (/showthread.php?tid=25906) |
Repopulating form fields - El Forum - 12-30-2009 [eluser]frist44[/eluser] I'm using some validation rule sets on my form and I'm noticing that <?=set_value('name')?> only works on fields that were validated. I have some fields that aren't necessarily required, but I'm putting some much less restrictive rule on them just to get the set_value function to work. Is there a helper-style rule to repopulate fields that do not include a validation rule? Thanks! Repopulating form fields - El Forum - 12-30-2009 [eluser]flaky[/eluser] instead of Code: <?=set_value('name')?> Code: <?=$this->input->post('name');?>; Repopulating form fields - El Forum - 12-30-2009 [eluser]Neeraj Kumar[/eluser] I would really suggest you to use validation on non required fields also. Using CI's native functions will keep your app clean. Repopulating form fields - El Forum - 12-30-2009 [eluser]Ollie Rattue[/eluser] [quote author="Codemaster Snake" date="1262211215"]I would really suggest you to use validation on non required fields also. Using CI's native functions will keep your app clean.[/quote] Yes I would agree that you should use CI validation for all form fields, as it makes the controler code completely clear. If you don't need a field to be required you can in fact set a fieldname without any validation rules, or as I usually do with xss_clean and trim. Example code: Code: $this->form_validation->set_rules('location','Location',''); Repopulating form fields - El Forum - 12-30-2009 [eluser]Neeraj Kumar[/eluser] @ollie is absolutely correct, check the way he omitted the 'required' from the list Repopulating form fields - El Forum - 12-30-2009 [eluser]frist44[/eluser] If you enable the xss global setting in the config file, those xss_clean rules can be removed from individual rules right? Repopulating form fields - El Forum - 12-30-2009 [eluser]Ollie Rattue[/eluser] [quote author="frist44" date="1262226186"]If you enable the xss global setting in the config file, those xss_clean rules can be removed from individual rules right?[/quote] Correct. |