[eluser]Unknown[/eluser]
Hi guys, I'm receving a 500 Internal Server error on form submission.
The form uses post as method and the action is on the same page. It's address is
Code:
index.php/controller/edit/id
where edit is the controller method and the id is a numeric parameter.
Code:
function edit($id)
{
if($this->input->post('save')){
$this->form_validation->set_rules(Category::NAME, Category::NAME, 'trim|required|alpha_dash');
$this->form_validation->set_rules(Category::PERCENTAGE, Category::PERCENTAGE, 'trim|required|numeric');
$this->form_validation->set_rules(Category::AVAILABLE, Category::AVAILABLE, 'trim|numeric');
if($this->form_validation->run())
{
$category_array = array(
Category::CATID => $id,
Category::NAME => $this->form_validation->set_value(Category::NAME),
Category::PERCENTAGE => $this->form_validation->set_value(Category::PERCENTAGE),
Category::AVAILABLE => $this->form_validation->set_value(Category::AVAILABLE) ? 1 : 0,
);
if($this->category->update($category_array))
$data['message'] = array('type' => 'success', 'message' => 'ok message');
else
$data['message'] = array('type' => 'error', 'message' => 'not ok message');
}else
$data['message'] = array('type' => 'error', 'message' => 'not ok message');
}
$data['category'] = $this->category->get_category($id);
if(!$data['category'])
redirect('categories');
$output = $this->load->view('common/header', $data, true);
$output .= $this->load->view('categories/edit', $data, true);
$output .= $this->load->view('common/footer', $data, true);
$this->output->set_output($output);
}
As you can see the script is very simple, and I figured out that the run method of form validation library is what is giving me the problem. In particular if I comment the if out it runs well also if in the run method I comment out the return line :O
Any idea on what it could be the problem ?