multi page forms and genral form question - 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: multi page forms and genral form question (/showthread.php?tid=23421) |
multi page forms and genral form question - El Forum - 10-10-2009 [eluser]The Casual Bot[/eluser] I'm brand new to CI this is my first time working with a framework as normal i work in just PHP So first was gutted about how much time i wasted in the last 2 year using PHP alone mirk: Iv been asked to crate i form set to take personal details over about 8 pages there current ones pass the post data into hidden forms but it this does have problems as when the back button is used the data gets lost and the user sends a half full application. iv done something similar before using just PHP and the session variables so even when the user pressed the back button it did lose and data so to my question has anyone got any ideas on how best to code a multi page form and the logic they used (or would use) that would also display the data in the fields when the back button is used ??? and question 2 iv looked in the user guide but can find my answer to this iv turned on xss clean globally do i use the post values form my form or are they stored some where else Thanks In Advanced :-) multi page forms and genral form question - El Forum - 10-10-2009 [eluser]darkhouse[/eluser] The way I've done this in the past is to process (validate) each step individually, and on success add the data to the session. For each field, use the form helper, like this: Code: <input type="text" name="first_name" value="<?php echo set_value('first_name', $this->session->userdata('first_name')); ?>" /> So if the page has been posted, but is missing some data or something, this function will display the data that was posted in the field, or if you're going back, it'll display the data from the session. multi page forms and genral form question - El Forum - 10-10-2009 [eluser]The Casual Bot[/eluser] Got it i did now i could set send a second value to set_value i have however had made a change to the session lib but unsure if this is the best way to do it i wanted to use a multidimensional array to store the form data as per page if you get me iv added to session lib Code: function userdataarray($item, $item1) is this the nest way or do you know a better one multi page forms and genral form question - El Forum - 10-10-2009 [eluser]The Casual Bot[/eluser] just tried it and it work perfectively multi page forms and genral form question - El Forum - 10-10-2009 [eluser]darkhouse[/eluser] In that case I would send the session data to the view from the controller, like this: Code: $data = array('formdata' => $this->session->userdata('formdata')); And then in the view, the input would be this: Code: <input type="text" name="first_name" value="<?php echo set_value('first_name', $formdata['first_name']); ?>" /> That way you don't need to modify the session class. multi page forms and genral form question - El Forum - 10-10-2009 [eluser]The Casual Bot[/eluser] i can get this to work every time the page loads i get Code: A PHP Error was encountered the controller looks like this Code: $data = array('formdata'); and the field is Code: <input name="name" type="text" id="name" class="element text medium" value="<?php echo set_value('name', $data['name'] ); ?>" maxlength="255"/> multi page forms and genral form question - El Forum - 10-10-2009 [eluser]The Casual Bot[/eluser] :red: stupid error i my controller with was Code: $data = array('formdata'); changed to Code: $data = array('formdata' => $this->session->userdata('1')); thanks multi page forms and genral form question - El Forum - 10-10-2009 [eluser]darkhouse[/eluser] Just remember to use $formdata['name'] in your set_value() function. You have $data right now, it should be $formdata. multi page forms and genral form question - El Forum - 10-11-2009 [eluser]The Casual Bot[/eluser] yeah got it Thank for your help fella |