[eluser]Robert May[/eluser]
I'm a bit confused as to how to use the validation. I can see how you make the form, but where should I submit it, back to the same function, ie submitting from index.php/auth/login to index.php/auth/login?
I'm confused!
Is it meant to be like this (which I'm not sure would work):
Code:
class Auth extends Controller {
function Auth()
{
parent::Controller();
}
function index()
{
$this->session->keep_flashdata('refer');
$this->load->library('form'); // first of all we have to load the library
$form = new Form(); // then we instantiate a new form object
$form // and fill it with elements
->open('auth/login')
->text('author_name', 'Username/email:', 'trim|alpha_numeric|max_length[255]|xss_clean')
->pass('author_password', 'Password:', 'trim|alpha_numeric|max_length[20]|xss_clean')
->reset()
->submit();
$data['form'] = $form->get(); // this returns the validated form as a string
$data['errors'] = $form->errors; // this returns validation errors as a string
$content = $this->load->view('auth', $data, TRUE);
$data = array(
'page_title' => 'Login',
'sub_heading' => 'Please login to continue',
'content' => $content,
);
$this->templater->build($data);
}
function login()
{
$data['form'] = $form->get(); // this returns the validated form as a string
$data['errors'] = $form->errors; // this returns validation errors as a string
$form->validate();
if ($form->valid)
{
do something
}