[eluser]Bramme[/eluser]
Okay, I'm using the new form validation library, but it doesn't seem to be working and I don't see anything I'm doing wrong.
controller:
Code:
function register() {
$this->load->library('form_validation');
$data['register_form'] = array(
'name' => array('name' => 'name', 'value' => set_value('name')),
'password' => array('name' => 'password', 'value' => ""),
'password_check' => array('name' => 'password_check', 'value' => ""),
'email' => array('name' => 'email', 'value' => set_value('email')),
'question' => array('name' => 'question', 'value' => set_value('question')),
'answer' => array('name' => 'answer', 'value' => set_value('answer')),
'submit' => array('name' => 'subm_registration', 'value' => 'Register')
);
if ($this->form_validation->run('register') == TRUE)
{
$this->template->write_view('ciforum_content', 'ciforum/register_success');
}
else {
$this->template->write_view('ciforum_content', 'ciforum/register', $data);
}
$this->template->render();
}
My rules are set in a config file
Code:
$config = array(
'register' => array(
array(
'field' => 'name',
'label' => 'username',
'rules' => 'trim|required|xss_clean'
),
array(
'field' => 'password',
'label' => 'password',
'rules' => 'trim|required|min_lenght[6]|xss_clean'
),
array(
'field' => 'password_check',
'label' => 'second password',
'rules' => 'trim|required|matches[password]|xss_clean'
),
array(
'field' => 'email',
'label' => 'e-mail address',
'rules' => 'trim|required|xss_clean'
),
array(
'field' => 'question',
'label' => 'secret question',
'rules' => 'trim|required|xss_clean'
),
array(
'field' => 'answer',
'label' => 'answer',
'rules' => 'trim|required|xss_clean'
)
)
);
and the form looks like this:
Code:
<?= form_open($this->uri->uri_string()) ?>
<p><?= validation_errors() ?></p>
<ul class="form_table">
<li><?= form_label("<span>Your name</span>", "form_input", $register_form['name']) ?></li>
<li><?= form_label("<span>Your password</span>", "form_password", $register_form['password']) ?></li>
<li><?= form_label("<span>Enter again</span>", "form_password", $register_form['password_check']) ?></li>
<li><?= form_label("<span>Your e-mail</span>", "form_input", $register_form['email']) ?></li>
<li><?= form_label("<span>Your super secret question</span>", "form_input", $register_form['question']) ?></li>
<li><?= form_label("<span>The super secret answer</span>", "form_input", $register_form['answer']) ?></li>
<li class="right"><?= form_submit($register_form['submit']) ?></li>
</ul>
<?= form_close() ?>
Can anyone of you see something wrong?