[eluser]The Revel[/eluser]
I made myself a form with validation rules, that upon validate, it does some SQL work, else it shows the form. However when i load the page for the first time, it shows me validation errors because nothign has been filed out yet.
The format i have is as follows (code condensed as its a lotta code):
Code:
//validate form input
$this->form_validation->set_rules('qty1', 'First Quantity', 'required|xss_clean');
$this->form_validation->set_rules('pr1', 'First Price', 'required|xss_clean');
$this->form_validation->set_rules('admin', 'Admin ID', 'required|xss_clean');
if ($this->form_validation->run() == true)
{
//Run SQL Queries, do some back end work
//...
//If Successful set the flashdata message
$this->session->set_flashdata('message', "Transaction(s) Added");
//Pass a viable back using flashdata
$this->session->set_flashdata('searchcode', $this->input->post('searchcode', true));
//redirect them back
redirect('auth/search_scancode/', 'refresh');
}
else
{
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
// pass form value ararys
// ...
$this->template
->title( 'My Site', 'Print Card')
->set_layout('default')
->build('auth/scan_view', $this->data);
}
Is there a way to prevent the passing of the validation errors when nothing has been entered to begin with?