[eluser]Brad K Morse[/eluser]
SOLVED: had to print form_hidden() and the step_attributes array was off, now I printed print form_hidden('step_id[]', $id); w/i the loop in confirmation-view
UPDATE: The all-results-view source-code appearing in the confirmation-view was due to my browser caching it.
Now that I was able to see the confirmation-view source code, I noticed it did not display the hidden fields in the source-code. I commented out everyone except the message form_hidden one, but it still did not display them.
Just tried
Code:
print form_hidden('step_id', '2'); and it showed up in source
This controller submits information posted from a form.
v1.7.2 [b]autoload file:[/b]
[code]$autoload['helper'] = array('url', 'text', 'form');
$autoload['libraries'] = array('database','Adldap', 'session');
form_submit()'s for each form:
Code:
print form_submit('confirm_first', 'Submit');
print form_submit('confirmed', 'Submit');
First the info is posted to a
confirmation-view, that prints out what the user posted, and asks them to make sure everything is correct before inserting into the database.
Once $this->input->post('confirmed') is true, it posts the data, runs it thru the _
insert private controller.
submit controller:
Code:
function submit() {
$this->output->enable_profiler(TRUE);
if($this->session->userdata('is_logged_in')) {
if(!$this->input->post('confirm_first') && !$this->input->post('confirmed')) {
// display form if not submitted
$data['outcome_message'] = "Please complete the form below";
$this->_loadForm($data);
} elseif ($this->input->post('confirm_first') && $this->input->post('step_id') && $this->input->post('message') && $this->input->post('department_id')) {
// if each field is completed, present confirm view
$data['message'] = $this->input->post('message');
$data['step_id'] = $this->input->post('step_id');
$data['department_id'] = $this->input->post('department_id');
$this->load->model('add_model');
$data['department_title'] = $this->add_model->getDepartmentTitle($this->input->post('department_id'));
$data['step_descriptions'] = $this->add_model->getStepTitles($this->input->post('step_id'));
$this->load->view('confirmation-view', $data);
} elseif ($this->input->post('confirmed') && $this->input->post('step_id') && $this->input->post('message') && $this->input->post('department_id')) {
// info confirmed, insert into SP_COMMENTS & SP_TRANSACTIONS table
$this->load->model('add_model');
$this->_insert($this->input->post('step_id'));
$data['outcome_message'] = "Thank you for submitting";
$this->load->view('comment-submitted-view',$data);
} else {
print '<h1>Did not meet any of the ifs of elses</h1>';
}
} else {
// redirects them to login
redirect('add/login');
}
}
private _insert controller:
Code:
function _insert($step_ids) {
$UUID = uniqid();
$this->add_model->insertComment($UUID);
$this->add_model->logTransaction($UUID, $step_ids);
}
The problem is, it shows the data appropriately on confirmation-view, but when I go to check the source, it displays the source for the all-results-view (which is odd because it shows the confirmation-view in the browser just as it should be), which is loaded within the
_loadForm private controller:
Code:
function _loadForm($data) {
$this->load->model('add_model');
$data['goals'] = $this->add_model->getGoals('SP_GOALS');
$data['objectives'] = $this->add_model->getObjectives('SP_OBJECTIVES');
$data['steps'] = $this->add_model->getSteps('SP_STEPS');
$data['departments'] = $this->add_model->getDepartments();
$this->load->view('all-results-view',$data);
}
When $this->input->post('confirmed') && $this->input->post('step_id') && $this->input->post('message') && $this->input->post('department_id') is true, seen in the second elseif of submit controller, it actually does not return true, because step_id is empty.
Unsure why step_id is not being posted from the
confirmation-view page, code as follows:
screen shot of confirmation-view:
http://cl.ly/2F0k0E3L1N251X1m3q1C
Code:
<?php
$data['page_title'] = "Please Confirm";
$this->load->view('include/header', $data); ?>
<h1>Please Confirm</h1>
<h3>Department</h3>
<p><?=$department_id.' '.$department_title?></p>
<h3>Message</h3>
<pre><?=$message?></pre>
<h3>Action Steps selected</h3>
<?php
print form_open(uri_string()); // open form tag
/* ----- Storing values into hidden inputs for post ----- */
$message_attributes = array(
'name' => 'message',
'value' => $message
);
form_hidden($message_attributes);
form_hidden('department_id', $department_id);
<?php
foreach($step_id as $id) {
$step_attributes = array(
'name' => 'step_id[]',
'value' => $id
);
form_hidden($step_attributes);
}
foreach($step_descriptions as $r) {
print '<p><strong>Action Step '.$r->SP_STEPS_RANK.'</strong> '.$r->SP_STEPS_DESCRIPTION.'</p>';
}
print '<p>'.form_submit('confirmed', 'Submit').' <a href="[removed]history.go(-1)" title="Go Back" class="not-correct-button">Not correct, go back</a></p>'; // submit button
print form_close();
?>
<?php $this->load->view('include/footer'); ?>