Welcome Guest, Not a member yet? Register   Sign In
yet more form validation 1.7
#11

[eluser]Matthieu Fauveau[/eluser]
You should force the rules loading with set_rules to be sure the problem is not elsewhere.
#12

[eluser]soupdragon[/eluser]
i'm not sure if this is what you mean but i now have this .....but it makes no diffence

$this->form_validation->set_rules($this->config->item('seller/seller_reg'));
if ($this->form_validation->run('seller/seller_reg') != FALSE)
#13

[eluser]soupdragon[/eluser]
bump......help please
#14

[eluser]TheFuzzy0ne[/eluser]
Code:
'Seller/seller_reg' => array( // This should be all lowercase...
#15

[eluser]soupdragon[/eluser]
previously it was Seller(everywhere) - it is now changed throughout to lowercase which makes no difference whatsoever appart from visually
#16

[eluser]pistolPete[/eluser]
Did you try putting your validation rules directly into the controller instead of using a config file?
#17

[eluser]soupdragon[/eluser]
I am afraid i am going to have to boot this back up to the top, i was busy with another project but now back with this one.

Have tried adding my rules directly into the controller so:

#$this->form_validation->set_rules($this->config->item('seller/seller_reg'));

$config = array(
array(
'field' => 'seller_name',
'label' => 'langConfusedeller_name',
'rules' => 'trim|required|min_length[4]|max_length[12]|xss_clean|callback_username_check'
),
array(
'field' => 'seller_password',
'label' => 'langConfusedeller_password',
'rules' => 'trim|required|matches[passconf]|xss_clean'
),
array(
'field' => 'passconf',
'label' => 'lang:passconf',
'rules' => 'trim|required|xss_clean'
),
array(
'field' => 'firmname',
'label' => 'lang:firmname',
'rules' => 'trim|required|xss_clean'
),
array(
'field' => 'firstname',
'label' => 'lang:firstname',
'rules' => 'trim|required|xss_clean'
),
);

$this->form_validation->set_rules($config);

but it makes no difference.

Can someone please give me a clue where i should be looking?
#18

[eluser]TheFuzzy0ne[/eluser]
Please repost your controller method in it's entirety (and please use code tags Smile ).
#19

[eluser]soupdragon[/eluser]
ok

Code:
function seller_reg()
     {

        $this->base = $this->config->item('base_url');
        $this->css = $this->config->item('css');
        $data['css'] = $this->css;
        $data['base'] = $this->base;
        $this->load->library('session');

        $data['webTitle'] = ' Seller werden';
        $data['extraHeadContent'][] = '<link rel="stylesheet" type="text/css" href="./css/seller.css" media="screen"/>';
        $data['page'] =  'seller/seller_reg';
        
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        
        #Dropdown attributes
        $extras['type'] = array('1' => 'privat', '2' => 'firma');


        if(is_numeric($this->session->userdata('sellerid'))) {
            # $data['form'] = $this->createForm('selleredit', $extras);
            $this->seller_edit();
        } else {
            $data['form'] = $this->createForm('index', $extras);    
        }
#commented out validation moved here
        #$this->form_validation->set_rules($this->config->item('seller/seller_reg'));

$config = array(
                                   array(
                                            'field' => 'seller_name',
                                            'label' => 'lang:seller_name',
                                            'rules' => 'trim|required|min_length[4]|max_length[12]|xss_clean|callback_username_check'
                                         ),
                                    array(
                                            'field' => 'seller_password',
                                            'label' => 'lang:seller_password',
                                            'rules' => 'trim|required|matches[passconf]|xss_clean'
                                         ),
                                    array(
                                            'field' => 'passconf',
                                            'label' => 'lang:passconf',
                                            'rules' => 'trim|required|xss_clean'
                                         ),
                                    array(
                                            'field' => 'firmname',
                                            'label' => 'lang:firmname',
                                            'rules' => 'trim|required|xss_clean'
                                         ),
                                    array(
                                            'field' => 'firstname',
                                            'label' => 'lang:firstname',
                                            'rules' => 'trim|required|xss_clean'
                                         ),                
                              );

$this->form_validation->set_rules($config);


    if ($this->form_validation->run('seller/seller_reg') != FALSE)
        {            
        # pass values to insert
        $data['seller'] = $this->createForm('insert');

        # end form creation test
            # all validated so go dump in db - in a model
            $this->load->model('sellers');
            $sid = $this->sellers->insertnewseller($data['seller']);
            if((is_numeric($sid))&&($sid > 0)) {

             $data['seller_name'] = $data['seller']['seller_name'];
             $this->session->set_userdata('seller_name',  $data['seller']['seller_name']);

                $this->load->model('email_model');

                $this->email_model->send('register', $_POST);
                $data['page'] =  'seller/toconfirm';

            } else {
                $data['page'] =  'start/contact';
                $data['error'] ='Ooops somethings gone wrong';

            }
        }
        $this->load->view('container' , $data);
     }

    # -------------------------------------------------------------------------

The form fields are being refilled btw.
#20

[eluser]TheFuzzy0ne[/eluser]
If the form fields are being repopulated, then the validation is being run. So what's the problem exactly?

Scrap that. It still doesn't confirm anything, as set_value() simply returns the values from the post array. But even still, what's the problem you're experiencing? The more verbose you can be, the more chance we have of getting to the bottom of this.

EDIT: Try removing 'seller/seller_reg' from the call to $this->validation->run().




Theme © iAndrew 2016 - Forum software by © MyBB