CodeIgniter Forums
set_value, set_select, set_radio - 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: set_value, set_select, set_radio (/showthread.php?tid=30762)



set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]MexiTek[/eluser]
I have noticed that when I use set_value(), set_select() or set_radio() they only work on the fields that have been passed through $this->form_validation->set_rules() function on the controller side.

I am sure I am just missing something. Has anyone had this problem before?


set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]WanWizard[/eluser]
You haven't missed anything, this is by design.


set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]MexiTek[/eluser]
So....What if I want to use these helper functions to repopulate fields that do not require validation? Is there some sort of work around?


set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]WanWizard[/eluser]
In principle every piece of user input requires validation, as it can be manipulated.
You can work around that by validating them with an empty rule set.


set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]MexiTek[/eluser]
I'll do that. Thanks for the help!


set_value, set_select, set_radio - El Forum - 05-25-2010

[eluser]pickupman[/eluser]
[quote author="WanWizard" date="1274819719"]In principle every piece of user input requires validation, as it can be manipulated.
You can work around that by validating them with an empty rule set.[/quote]
+1...at least use
Code:
$this->form_validation->set_rules('field', 'field name', 'trim');

Trim may a little silly for radios and checkboxes, but you never know when some will manipulate your forms to be a little mischievous.