Welcome Guest, Not a member yet? Register   Sign In
Problem using Form Validation library
#1

[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>&lt;?= validation_errors() ?&gt;</p>
<ul class="form_table">
    <li>&lt;?= form_label("<span>Your name</span>", "form_input", $register_form['name']) ?&gt;</li>
    <li>&lt;?= form_label("<span>Your password</span>", "form_password", $register_form['password']) ?&gt;</li>
    <li>&lt;?= form_label("<span>Enter again</span>", "form_password", $register_form['password_check']) ?&gt;</li>
    <li>&lt;?= form_label("<span>Your e-mail</span>", "form_input", $register_form['email']) ?&gt;</li>
    <li>&lt;?= form_label("<span>Your super secret question</span>", "form_input", $register_form['question']) ?&gt;</li>
    <li>&lt;?= form_label("<span>The super secret answer</span>", "form_input", $register_form['answer']) ?&gt;</li>
    <li class="right">&lt;?= form_submit($register_form['submit']) ?&gt;</li>
</ul>
&lt;?= form_close() ?&gt;

Can anyone of you see something wrong?


Messages In This Thread
Problem using Form Validation library - by El Forum - 10-18-2008, 08:18 AM
Problem using Form Validation library - by El Forum - 10-18-2008, 08:54 AM
Problem using Form Validation library - by El Forum - 06-30-2009, 02:20 PM
Problem using Form Validation library - by El Forum - 07-01-2009, 01:19 AM
Problem using Form Validation library - by El Forum - 07-01-2009, 03:49 AM
Problem using Form Validation library - by El Forum - 07-01-2009, 04:16 AM
Problem using Form Validation library - by El Forum - 07-01-2009, 04:26 AM
Problem using Form Validation library - by El Forum - 07-01-2009, 06:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB