Monday, February 10, 2014

Validation problem

Hi!
I try to create some validation to my form. I followed some forums and blogs looking for solution, but nothing helps.

My controller looks like this:

public function add() {
        if ($this->request->is('post')) {
            $this->Student->create();
            if ($this->Student->validates()) {
.....

And my model validation:

public $validate = array(
         'firstname' => array(
            'alphaNumeric' => array(
                'rule'     => 'alphaNumeric',
                'required'    =>    true,
                'message'  => 'Tylko litery w imieniu'
            ),
            'minLength' => array(
                'rule'    => array('minLength', '3'),
                'required'    =>    true,
                'message' => 'Wpisz pełne imię'
            )
        ), ......

When I remove "required => true" form passes validation even with errors! When I enable "required => true" form fails each time, even when correct. The only field that works correct is email:
'email' => array('email', true),

When I show debug($this->Student->data) all data is there. However I suppose, that somehow validation may be somehow unable to see this.

Please help me find solution to this problem.
Regards,
Slawek.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: