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

[eluser]soupdragon[/eluser]
I am trying to update to 1.7........but having difficulties

controller
Code:
class Seller extends Controller {
        var $ci;
    function __construct()
    {
    parent::Controller();
   }

# -------------------------------------------------------------------------    
   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['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'))) {
            $this->seller_edit();
        } else {
            $data['form'] = $this->createForm('index', $extras);    
        }

    if ($this->form_validation->run() != FALSE)
        {            
        # pass values to insert
        $data['seller'] = $this->createForm('insert');
I AM GETTING HERE ALTHOUGH THE DATA IS WRONG
# bit cut
    } else {
        $data['page'] =  'start/contact';
        $data['error'] ='Ooops somethings gone wrong';
    }
    $this->load->view('container' , $data);
     }

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

and my validation rules are in config/form_validation.php
$config = array(
'Seller/seller_reg' => 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'
                                         ),                
                              );

somehow my validation rules are not being called, i had this working with the old ci form validation and i am sure this is a stupid error but i have tried a lot without sucess, so please help :-)

Edit by Michael Wales: Wrapped in code tags
#2

[eluser]Matthieu Fauveau[/eluser]
You need to load your form validation config file... it's in the doc.

Code:
$this->form_validation->set_rules($this->config->item('Seller/seller_reg'));

if ($this->form_validation->run() != FALSE)
{

Regards.
#3

[eluser]soupdragon[/eluser]
nope thats not it !

make no difference

and anyway thats not true....according to the documentation

When a rule group is named identically to a controller class/function it will be used automatically when the run() function is invoked from that class/function.
#4

[eluser]xwero[/eluser]
seller instead of Seller.
#5

[eluser]soupdragon[/eluser]
nope - changed Seller to seller in both controller, and for_validation
makes no difference
#6

[eluser]xwero[/eluser]
Do you use a route to get to your method?
#7

[eluser]soupdragon[/eluser]
....looks round in panic....what do you mean ? :-)
#8

[eluser]xwero[/eluser]
do you use site.com/sellers/seller_reg or site.com/sellers/registration (or a variation) to get to your method.
#9

[eluser]pistolPete[/eluser]
http://ellislab.com/codeigniter/user-gui...uting.html
#10

[eluser]soupdragon[/eluser]
oh that routing ...to the controller (is it not?)
i use sellers/seller_reg


EDIT
... i assume then that from the lack of immediate answers that basically what i have done is correct, just there is an error or bug somewhere?




Theme © iAndrew 2016 - Forum software by © MyBB