Display form results on same page as form (allowing to quickly edit) |
[eluser]mfroseth[/eluser]
I'm building a rate calculator for insurance rates which can be seen at http://newco.ratecal.info Right now the data is submitted and brought to a new page (results). I would like to display the form on the same page, allowing for them to easily update rates requested, etc... In CodeIgniter, how do I go about duplicating the form, but preopulating the fields with the data submitted? I have the data stored in a session and can pull that but I am unsure as to how I can place that value in the texboxes, drop downs/radio buttons. I'm using the form helper.
[eluser]Cristian Gilè[/eluser]
Each form has its own submit button. The action of each form will be different. One will point to the new method and one to the update method. Use set_value to populate the update form: it accepts 2 parameters, field name AND value.
[eluser]mfroseth[/eluser]
Where does set_value come into play? I haven't seen this in the documentation yet (maybe not there yet). Would you be able to give a simple code example? This is what I have for the first drop down: Code: <?php
[eluser]Cristian Gilè[/eluser]
http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]mfroseth[/eluser]
[quote author="Cristian Gilè" date="1338838568"]http://ellislab.com/codeigniter/user-gui...elper.html[/quote] Is this possible using the CI form helpers? example: Code: <?php echo form_input('face_amount_level',''); ?>
[eluser]Cristian Gilè[/eluser]
You can populate a form input as follows: Code: $data = array( where $username is a value passed from the controller to the view.
[eluser]mfroseth[/eluser]
[quote author="Cristian Gilè" date="1338839676"]You can populate a form input as follows: [code $data = array( 'name' => 'username', 'id' => 'username', 'value' => set_value('username',$username) ); echo form_input($data);[/code] where $username is a value passed from the controller to the view.[/quote] Thanks for all the help. I've attempted this with the following code: Code: <?php Am I doing something wrong? Seems to only add a blank option to the select menu.
[eluser]Cristian Gilè[/eluser]
Code: if($this->session->userdata('plan_type') == "graded") { $plan = "graded"; } else { $plan = "level"; } |
Welcome Guest, Not a member yet? Register Sign In |