Welcome Guest, Not a member yet? Register   Sign In
Display form results on same page as form (allowing to quickly edit)
#1

[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.
#2

[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.
#3

[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
if($this->session->userdata('plan_type') == "graded")
{
  $options = array('graded' => 'Final Expense Graded Death Benefit',  'level' => 'Final Expense Level Death Benefit');  
} else if($this->session->userdata('plan_type') == "level")
{
  $options = array('level' => 'Final Expense Level Death Benefit','graded' => 'Final Expense Graded Death Benefit', );  
} else
{
  $options = array('default' =>'Select A Plan','graded' => 'Final Expense Graded Death Benefit', 'level' => 'Final Expense Level Death Benefit');
}
?>
    <?php echo form_dropdown('plan_type', $options, 'required','id="plan_type"'); ?>
#4

[eluser]Cristian Gilè[/eluser]
http://ellislab.com/codeigniter/user-gui...elper.html
#5

[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',''); ?>
#6

[eluser]Cristian Gilè[/eluser]
You can populate a form input as follows:

Code:
$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => set_value('username',$username)
            );

echo form_input($data);

where $username is a value passed from the controller to the view.
#7

[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
if($this->session->userdata('plan_type') == "graded") { $plan = "Graded"; } else { $plan = "Level";
$options =
array('default' =>'Select A Plan',
    'graded' => 'Final Expense Graded Death Benefit',
    'level' => 'Final Expense Level Death Benefit',
    'value' => set_select('plan_type', $plan)
    );
?>
    <?php echo form_dropdown('plan_type', $options); ?>

Am I doing something wrong? Seems to only add a blank option to the select menu.
#8

[eluser]Cristian Gilè[/eluser]
Code:
if($this->session->userdata('plan_type') == "graded") { $plan = "graded"; } else { $plan = "level"; }

$options = array('default' =>'Select A Plan',
                 'graded' => 'Final Expense Graded Death Benefit',
                 'level' => 'Final Expense Level Death Benefit'
                );
echo form_dropdown('plan_type', $options, set_select('plan_type', $plan));




Theme © iAndrew 2016 - Forum software by © MyBB