Jump to content

CakePHP validation problem


[dx]

Recommended Posts

Hi,

 

I'm new with cakePHP and trying to make form validation. It just won't validate...

 

This is my code:

 

// Users/test.ctpecho $this->Form->create(); echo $this->Form->input('firstname');echo $this->Form->end('Test');
// UsersController.phpclass UsersController extends AppController {    public function test() {        if ($this->request->is('post')) {            $this->User->set($this->request->data);            if ($this->User->validates()) {                pr('no errors');            } else {                pr($this->User->validationErrors);            }        }    }}
// UserModel.phpclass User extends AppModel {        public $validate = array(        'firstname' => array(            'between' => array(                'rule' => array('between', 3, 50),                'message' => 'Firstname must be between 3 and 50 characters long.',            ),            'notEmpty' => array(                'rule' => 'notEmpty',                'message' => 'You must provide first name!'            )        )    );}

Best regards!

 

Link to comment
Share on other sites

That's awfully vague. How is it not validating? What do the docs say? What do you expect and what are you seeing?

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...