CodeIgniter Forums
set_value is only working for fields that have validation? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: set_value is only working for fields that have validation? (/showthread.php?tid=20739)



set_value is only working for fields that have validation? - El Forum - 07-20-2009

[eluser]otherjohn[/eluser]
Hi all, I am using form validation on a page and for some reason only input fields that I have set form valitation rules to will auto fill. The rest are blank. Does anyone know how to fix this?
For example
if I have something like "firstname" required
Code:
$this->form_validation->set_rules('firstname', 'First Name', 'required');
and on the view have
Code:
<input id="firstname" name="firstname" type="text" class="field text" value="<?php echo set_value('firstname'); ?>" size="8" tabindex="10" />
AND
Code:
<input id="lastname" name="lastname" type="text" class="field text" value="<?php echo set_value('lastname'); ?>" size="14" tabindex="11" />

LASTNAME input doesn't auto fill but firstname does.
Validation works correctly though. Any thoughts?


set_value is only working for fields that have validation? - El Forum - 07-20-2009

[eluser]Sbioko[/eluser]
Look in the source code of this library and get your answer.


set_value is only working for fields that have validation? - El Forum - 07-20-2009

[eluser]Evil Wizard[/eluser]
Yes the set_value() helper method uses the CI validation object to repopulate the input values, but you can leave the rules blank, or just use trim() as the input rules and the set_value() method will work.


set_value is only working for fields that have validation? - El Forum - 07-20-2009

[eluser]otherjohn[/eluser]
kk ty