Welcome Guest, Not a member yet? Register   Sign In
Form validation
#1

[eluser]callumd[/eluser]
Hi there,

CodeIgniter noob here, still trying to learn the ropes.

So I've been playing with CI's Form_Validation class, and according to the user manual, the following is proper:

Quote:$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');

$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');

What struck me as odd about this is that all the form rules are being set before the system even knows if this is a form submission attempt. Seems like a real waste of resources, and bad logic.

Is there a better way to do it, and if so, why doesn't it appear in the documentation?

Thanks in advance.


Messages In This Thread
Form validation - by El Forum - 11-07-2008, 12:21 AM
Form validation - by El Forum - 11-07-2008, 01:06 AM
Form validation - by El Forum - 11-07-2008, 01:07 AM
Form validation - by El Forum - 11-07-2008, 01:12 AM
Form validation - by El Forum - 11-07-2008, 01:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB