Welcome Guest, Not a member yet? Register   Sign In
print all data that has been posted in form, into confirmation view
#1

[eluser]Brad K Morse[/eluser]
I am creating a confirmation view, and I need to grab all the data that was posted from a post and pass it into that view.

There must be a simple way of doing this...

something like...

Code:
$data[] = $this->input->post('name_of_form');
$this->load->view('confirmation-view', $data);

Then within the view, I can print it out like:

Code:
<?=$first_name?>

<?=$last_name?>

<?=$email?>

Trying to avoid:

Code:
$data['email'] = $this->input->post('email'); $data['first_name'] = $this->input->post('first_name'); ...

or if there is a better way of creating confirmation before db insertion, I am all ears.

Thank you.

UPDATE:

Controller

Code:
$data['steps'] = $this->input->post('step_id[]');
$data['message'] = $this->input->post('message');
$data['department_id'] = $this->input->post('department_id');
$this->load->view('confirmation-view',$data);

Problem now is storing the step_id[] appropriately, it does not display in the confirmation view. step_id[] is a series of checkboxes, that have the same name (step_id[]), I do not know how to store that array of values into the $data['steps'] array, to be passed into the confirmation view.

View

Code:
<h3>Department</h3>
<p>&lt;?=$department_id?&gt;</p>

<h3>Message</h3>
<pre>&lt;?=$message?&gt;</pre>

<h3>Steps</h3>
&lt;?php print_r($steps); ?&gt;

Resolved; Had to take the [] out of step_id in the post, so now it works with $data['steps'] = $this->input->post('step_id');

If there is a better way to do this, I am still all ears. Smile
#2

[eluser]Line 210[/eluser]
You could try this:

Code:
public function method_name()
{
    foreach($_POST as $key=>$value)
    {
        $data[$key] = $this->input->post($key);
    }

   $this->load->view('view_name', $data);
}
#3

[eluser]Line 210[/eluser]
For the checkboxes what I've done is given each checkbox a unique name and loop thru it like any other form element. Do they have to all be named the same?
#4

[eluser]Brad K Morse[/eluser]
Yes
#5

[eluser]Brad K Morse[/eluser]
Probably not the right way to accomplish this??

Controller:

Code:
$steps = $this->input->post('step_id');

foreach($steps as $step_id) {
    $this->load->model('add_model');
    $data['stepTitles'] .= $this->add_model->getStepTitles($step_id);
}
$this->load->view('confirmation-view',$data);

This is not working.
#6

[eluser]zac[/eluser]
It's hard to know for sure without seeing all of your code, but this may work:

$data['stepTitles'][$step_id] = $this->add_model->getStepTitles($step_id);
#7

[eluser]Brad K Morse[/eluser]
You are good, real good. Antoine Dodson good.




Theme © iAndrew 2016 - Forum software by © MyBB