[eluser]bluematt[/eluser]
I've managed to solve this, at least cosmetically...
My controller now uses a custom $form_validation->set_error() method instead of $form_validation->set_message():
Code:
if ($this->form_validation->run() && $this->types->create($this->input->post('type'))) {
redirect('admin/types');
} else {
$this->form_validation->set_error('type[name]', 'Cannot create a type with that %s.');
$this->view('admin/types_create');
}
And my customised Form_validation class:
Code:
class MY_Form_validation extends CI_Form_validation {
function __construct($config=array()) {
parent::__construct($config);
}
function set_error($field, $error) {
// This is checked by $form_validation->error_string()
$this->_error_array[$field] = sprintf($error, $this->_field_data[$field]['label']);
// This is checked by $form_validation->error()
$this->_field_data[$field]['error'] = sprintf($error, $this->_field_data[$field]['label']);
}
}