问题
Echoing previously saved data (excluding those from dropdown values) already works fine for me. I could see correct data saved for a particular record, however, after editing the form, I don't see anything successful after it. The data which were supposedly edited remain the same. Everything I typed to actually edit the echoed values went nowhere.
I currently have this in my controller:
public function edit_job()
{
$this->validateRole('client');
$this->load->model('job_model');
$id = $this->uri->segment(3,0);
$data['my_preference'] = $this->array_to_select( $this->job_model->get_all_categories(), 'id','name');
$data['job'] = $this->job_model->get_job($id);
$this->load->view('client/edit_job', $data);
}
public function edit_job_submit()
{
$this->validateRole('client');
$this->load->model('job_model');
if ( '0' != $_POST['id'] )
{
$this->job_model->edit_job($_POST);
} else {
$this->job_model->add_job($_POST);
}
redirect('client/manage_jobs?message=Job updated.');
}
While I have this in my model:
public function edit_job($obj)
{
$data = array
(
'title' => $post_obj['title'],
'description' => $post_obj['description'],
'start_date' => date("Y-m-d", strtotime($post_obj['start_date'])),
'category_id' => $post_obj['category_id']
);
$this->db->where('id', $id);
$this->db->update('job', $data);
}
回答1:
i think your problem is with this : redirect('client/manage_jobs?message=Job updated.'); instead use something like $this->load->view('success');
create a view called success and write a message saying success. put it after the update/insert function
Hope this helps
回答2:
I had to add $id = $obj['id']; to update particular entry attempted to be edited
来源:https://stackoverflow.com/questions/22850723/edit-form-echoes-previously-saved-data-correctly-but-does-not-update-the-form-fi