Problems with form validation/form helper and re-populate - 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: Problems with form validation/form helper and re-populate (/showthread.php?tid=19015) |
Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]albertone01[/eluser] Hello this is my controller: Code: function index() and this is my view: Code: <?php echo form_open('/Myview/index/'); ?> The first time it's all right, i can see correctly the values "Example" in the name input. If I submit the form i get this error over all my input form: Code: Severity: Notice why??? help Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]Dam1an[/eluser] You need to pass the $data rray into the view the second time as well like this Code: if ($this->form_validation->run() == FALSE){ Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]albertone01[/eluser] But in this way i have to put all post data into $data var... I would to repopulate the form in this way: http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#repopulatingform ... Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]Dam1an[/eluser] Right, now I'm with you (not thinking straight today) Even if it doesn't need the second value, it still looks for it, changing the view to this fixes the problem Code: <?php echo form_open('test/index'); ?> another solution would be to always initialise these to nothing in the controller and pass them in Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]albertone01[/eluser] Ok, now i don't have the error .... But I have not the posted value, I have 'noting' or '' ... Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]Dam1an[/eluser] You're just one problem after another Out of curiosity, why do you need to set the default as a variable? Won't it always be the same? So it could be hard coded Problems with form validation/form helper and re-populate - El Forum - 05-25-2009 [eluser]albertone01[/eluser] 'Couse I need to purpose to users some data, but they are free to change them... Ex. The user open the form: - name*: '' - surname*: '' - date*: 25/05/2009 Change: - name* = 'Alberto' - surname*: '' - date*: 28/06/2009 I check that che surname is empty Return to the form with the new values... |