How to preset my form fields and use the Validation class - 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: How to preset my form fields and use the Validation class (/showthread.php?tid=40447) |
How to preset my form fields and use the Validation class - El Forum - 04-08-2011 [eluser]TWP Marketing[/eluser] [edit] Ok, let me simplify the question. How do I pass field values to a form and use the validation library. view: Code: ... I've tried to pass my field value from the db: Code: ... I've been searching the forum, but find no discussion about the most recent version of the form_validation library. CI 2.0.1 Help? How to preset my form fields and use the Validation class - El Forum - 04-09-2011 [eluser]TWP Marketing[/eluser] [bump] I've simplified the question, but have had no success finding an answer... How to preset my form fields and use the Validation class - El Forum - 04-09-2011 [eluser]InsiteFX[/eluser] A simple way to do this would be to use session user_data Code: <input id="name" type="text" name="name" maxlength="255" value="<?php echo set_value('name', $this->session->userdata('name_value')); ?>" /> InsiteFX How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]TWP Marketing[/eluser] Insitefx, I see what you suggest, but don't see any material difference between a session var and a var passed to the view from the controller. Note that I am trying to implement the form_validation class: controller: Code: ... Code: ... So, How do I pass or preset the content of the form_validation field 'name'? Prior to CI 2, we had a function: set_field('name','some_name'), but that function is gone now, What replaces it? How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]InsiteFX[/eluser] Try this. When passing view data you use like $name not $view_data['name'] Controller: Code: ... View: Code: ... InsiteFX How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]TWP Marketing[/eluser] No luck, The form field displays blank, but the var: $name, does contain 'Charley Smith'. The form validation function: set_value('name',$name') does not pass the default value in the second parameter. Code: This works: How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]toopay[/eluser] try set array variable directly in your controller... How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]TWP Marketing[/eluser] toopay, which array variable are you referring to? How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]InsiteFX[/eluser] Try this Code: <input type="text" name="name" value="<?php echo set_value('name', $name);?>" size="50" /> InsiteFX How to preset my form fields and use the Validation class - El Forum - 04-10-2011 [eluser]toopay[/eluser] try send array var directly from your controller, like this... Code: // in your controller |