4
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by baig772
0

You forgot to specify with what ? Something you cannot find in the documentation ?

i am totally ne wto kohana. i ve read documentation but could not able to generate error messages on form validation. although validation is working but not able to generate errors :(

0

Can you post your code? And you might get more help in the Kohana forum.

the code in which validation is being done

private function validate()
        {
                $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){
                return $valid;
                }
                }
        }

the code where i want to generate error messages

public function createUser() {
        $validate   =   $this->validate();
        if ($validate) {
            $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 | Thankyou');

            $this->vContent = new View('message');
            $this->vContent->set('process', 'signUp');
            $this->vTemplate->set('content', $this->vContent->render(FALSE));
            $this->vTemplate->render(TRUE);
        } else {
            $this->captcha = new Captcha;
                
            $this->vTemplate->set('pageTitle', 'easyAd-admin | Signup');
            $this->vContent = new View('sign_up');
            $this->vContent->set('captcha', $this->captcha);
            $this->vContent->set('errors',$validate->error('form_error_messages'));
            $this->vTemplate->set('content', $this->vContent->render(FALSE));
            $this->vTemplate->render(TRUE);
           
                      
        }
    }

but in else condition i m getting 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"

0

i have read kohana documentation and put my query on discussion forum too but still no response

0

have you created an object? Perhaps it would help if you posted the relevant code (e.g. line 90 of user.php).

0

have you created an object? Perhaps it would help if you posted the relevant code (e.g. line 90 of user.php).

yes
line 90 is line 26 in posted code and i ve created an object in validate() function

0

Show your validate function. Problem is most likely there.

this is my validate function

private function validate()
    {
    $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){
    return $valid;
    }
    }
    }
0
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 | Thankyou');

                    $this->vContent = new View('message');
                    $this->vContent->set('process', 'signUp');
                    $this->vTemplate->set('content', $this->vContent->render(FALSE));
                    $this->vTemplate->render(TRUE);
                    }
                    
                   }
                    else{
                    $this->captcha = new Captcha;
               
                    $this->vTemplate->set('pageTitle', 'easyAd-admin | 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 i have removed the above error about calling function of a non object but still not getting error messages in the form

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.