Skip to content

Instantly share code, notes, and snippets.

@cakephp-tutorial
Created February 27, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cakephp-tutorial/5749240b8389c19140ff to your computer and use it in GitHub Desktop.
Save cakephp-tutorial/5749240b8389c19140ff to your computer and use it in GitHub Desktop.
<?php
#/app/Model/Book.php
class Book extends AppModel {
public $name = 'Book';
public $displayField ='title';
public $belongsTo = array('Author');
public $validate = array(
          'title' => array(
'rule' => array('notEmpty'),
             'required' => true,
             'allowEmpty' => false,
             'message' => 'Inserire il titolo del libro'
          ),
'description' => array(
'rule' => array('minLength', 30),
'required' => true,
'allowEmpty' =>false,
'message' => 'Descrizione obbligatoria.Lunghezza minima 30 caratteri.'
),
'isbn' => array(
'required' => true,
'allowEmpty' => false,
'rule' => array('rule' => array('minLength', 13)),
'message' => 'Codice Isbn non corretto ',
'unique' => array(
'rule' => 'isUnique',
'message' => 'Isbn già presente'
)
),
       );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment