[eluser]hugle[/eluser]
Hello Everyone.
I'm currently trying out CodeIgniter validation. And came up with some problems.
I have a function in my controller:
Code:
function register_form() {
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$rules['username'] = "required";
$rules['password'] = "trim|required|matches[passconf]";
$rules['passconf'] = "required";
$rules['email'] = "required|valid_email";
$this->validation->set_error_delimiters('<li>', '</li>');
$this->validation->set_rules($rules);
$fields['username'] = 'Username';
$fields['password'] = 'Password';
$fields['passconf'] = 'Password Confirmation';
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{
$out = $this->load->view('myform');
}
else
{
$out = $this->load->view('formsuccess');
}
return ($out);
}
(this function is basicaly from user guide)
Later, in 'function index' I do:
$content['middle'] = $this->register_form();
if I try to echo $content['middle'] I get empty page.
But If I for example try to navigate directrly index.php/register_form
I get myform.php view.
after some testings, I came up that:
when I change:
Code:
if ($this->validation->run() == FALSE)
{
$out = $this->load->view('myform');
}
else
{
$out = $this->load->view('formsuccess');
}
to smth like:
Code:
if ($this->validation->run() == FALSE)
{
$out = "a";
}
else
{
$out = "b";
}
I get output: "a" while accessing function index.
What I'm missing here or doing wrong?
Thanks everyone for help
cheers,
Jaroslav