Is it possible to display errors and repopulate fields on a form that is hard coded into a template? So far I’ve only figured out how to display the errors in a module’s view, but not a template. Based on the logic of EE, I’m guessing I need to somehow make the validation errors visible through a tag in my module, or even generate the whole form from the module, but I’m not sure how to best approach this.
Here is what I have right now.
function submit_form()
{
$this->EE->load->helper('form');
$this->EE->load->library('form_validation');
$this->EE->form_validation->set_rules('first_name', 'First Name', 'required');
$this->EE->form_validation->set_rules('last_name', 'Last Name', 'required');
$this->EE->form_validation->set_rules('address', 'Address', 'required');
$this->EE->form_validation->set_rules('city', 'City', 'required');
$this->EE->form_validation->set_rules('province', 'Province', 'required');
if ($this->EE->form_validation->run() == FALSE)
{
return $this->EE->load->view('form_errors');
}
else
{
// success
}
}And for testing, the view simply contains:
echo validation_errors();Can anyone help?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.