I realise this request goes against the example provided in the CI documentation (which advises a separate \'success\' page view), but I would like to reutilise a given form
The set_value function fetches its value from the Form_validation object and not from the $_POST array. The Form_validation object stores its own copy of the posted values in a variable called $_field_data.
Its a hack, but you could clear this variable after handling a successful submission :
class Item extends Controller
{
function Item()
{
parent::Controller();
$this->load->model('item_model');
}
function add()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'name', 'required');
$success = false;
if ($this->form_validation->run())
{
$this->item_model->add_item($this->input->post('name'));
$success = true;
// Look away now. Hack coming up!
// Clear the form validation field data
$this->form_validation->_field_data = array();
}
$this->load->view('item/add', array('success' => $success));
}
}