Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Users/test.ctp
- echo $this->Form->create();
- echo $this->Form->input('firstname');
- echo $this->Form->end('Test');
- // UsersController.php
- class 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.php
- class 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!'
- )
- )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement