[dx] Posted October 30, 2014 Share Posted October 30, 2014 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 More sharing options...
thescientist Posted October 31, 2014 Share Posted October 31, 2014 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 More sharing options...
[dx] Posted December 10, 2014 Author Share Posted December 10, 2014 Problem was User Model's filename. It should be just User.php Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now