编辑表单会正确回显先前保存的数据,但不会更新表单字段 [英] Edit form echoes previously saved data correctly but does not update the form fields
本文介绍了编辑表单会正确回显先前保存的数据,但不会更新表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
回复先前保存的数据(不包括从下拉列表中的数据)已经对我很好。我可以看到为特定记录保存的正确数据,但是,在编辑表单后,我没有看到任何成功后。应该编辑的数据保持不变。
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);
}
推荐答案
= $ obj ['id'];更新要编辑的特定条目
I had to add $id = $obj['id']; to update particular entry attempted to be edited
这篇关于编辑表单会正确回显先前保存的数据,但不会更新表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文