TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
kohana form validation
  • hi all i am new to kohana. i m using kohana 2.3.4. i have applied form validation but no error messages are displayed. kindly help me

  • Please give either more information or a crystal ball.

  • getting the following error " Fatal error: Call to a member function error() on a non-object in C:\xampp\htdocs\admin\application\controllers\user.php on line 90"

  • i have rendered the view containing form. now if it is not validated, just wanted to render that view again with error messages

  •            public function createUser() {
                $validate   =   new Validation($_POST);
                $validate->add_rules('firstName','required');
                $validate->add_rules('lastName','required');
                $validate->add_rules('userName','required');
                $validate->add_rules('password','required');
                $validate->add_rules('address','required');
                $validate->add_rules('email', 'required', 'email');
                if(Captcha::valid($_POST['captcha_response']))
                {
                    $valid  =   $validate->validate();
    
    
                    if ($valid) {
                        var_dump($valid);
                        $userData = array(
                        'first_name'    => $_POST['firstName'],
                        'last_name'     => $_POST['lastName'],
                        'user_email'    => $_POST['email'],
                        'user_password' => $_POST['password'],
                        'user_address'  => $_POST['address'],
                        'user_name'     => $_POST['userName']
                    );
                    $this->mUser->create($userData);
                    $this->vTemplate->set('pageTitle', 'easyAd-admin&nbsp;|&nbsp;Thankyou');
    
                    $this->vContent = new View('message');
                    $this->vContent->set('process', 'signUp');
                    $this->vTemplate->set('content', $this->vContent->render(FALSE));
                    $this->vTemplate->render(TRUE);
                    }
    
                   }
                    else{
                    //here i wan tto render error messages
                    $this->captcha = new Captcha;
    
                    $this->vTemplate->set('pageTitle', 'easyAd-admin&nbsp;|&nbsp;Signup');
                    $this->vContent = new View('sign_up');
                    $this->vContent->set('captcha', $this->captcha);
                    $this->vContent->set('errors',$validate->errors('form_error_messages'));
                    $this->vTemplate->set('content', $this->vContent->render(FALSE));
                    $this->vTemplate->render(TRUE);
    
    
                    }
    

    here is my code and i want to render error messages but not able to do so

  • Kohana 2.3.4 wtf? Kohana 2.x is not supported, 3.0 came out more than 2 years ago...

    If you are a newbie, then use 3.2 (the latest stable version)

  • @baig772, Is line 90 $this->vContent->set('errors',$validate->errors('form_error_messages'));? It's hard to help without being able to know what line is causing the error. I don't see any place where you have a call to error() (without the s) in your code.

  • @isaiah yes this line is line 90

  • above error is removed by doing validation in createUser() function but still not getting errors if form is not validated :(

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion