I'm attempting to use CodeIgniters form validation library, and despite my validation rules appearing to work, whenever I call validation_errors(), I get an empty string.
Here's a code snippet.
$base_rules = 'required|trim';
$this->_validation_rules = array(
array(
'field' => 'name',
'label' => 'name',
'rules' => $base_rules . '|alpha_numeric|min_length[5]|max_length[30]'
),
array(
'field' => 'price',
'label' => 'Price',
'rules' => $base_rules . '|decimal'
),
array(
'field' => 'duration',
'label' => 'Duration',
'rules' => $base_rules . '|integer'
),
array(
'field' => 'booking',
'label' => 'Booking',
'rules' => $base_rules . '|integer'
)
);
$this->form_validation->set_rules($this->_validation_rules);
if ($this->form_validation->run()) {
// do stuff
}else{
// prints an empty string
var_dump(validation_errors());
exit;
}
Does anyone know why this is the case, and how I can get my errors?