У меня есть некоторые проблемы с правилами проверки.Проверка модели в CakePHP
ОБНОВЛЕНО:
Warning (512): Could not find validation handler maxLength for lastname [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for firstname [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for phone [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for address [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for zipcode [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for city [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
Warning (512): Could not find validation handler maxLength for birth [CORE\Cake\Model\Validator\CakeValidationRule.php, line 281]
public $validate = array(
'username' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
'allowEmpty' => false,
'required' => true,
'message' => "Alphanumeric characters only.",
),
'between' => array(
'rule' => array('between',4,20),
'message' => "The username must be between %d and %d characters.",
),
'isUnique' => array(
'rule' => 'isUnique',
'message' => "This username is already taken.",
),
),
'password' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => "You must specify your password.",
),
),
'passwordconfirm' => array(
'between' => array(
'rule' => array('between', 8, 20),
'required' => true,
'message' => "The password must be between %d and %d characters.",
),
'equalTo' => array(
'rule' => array('equalToField', 'password'),
'message' => "Passwords are not identical.",
)
),
'oldpassword' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'required' => true,
'message' => "You must specify your old password.",
'on' => 'update',
),
),
'lastname' => array(
'maxLength' => array(
'rule' => array('maxLength', 25),
'required' => true,
'message' => "Your last name can't contain more than %d characters.",
),
),
'firstname' => array(
'maxLength' => array(
'rule' => array('maxLength', 25),
'required' => true,
'message' => "Your first name can't contain more than %d characters.",
),
),
'mail' => array(
'email' => array(
'rule' => array('email'),
'required' => true,
'message' => "You must specify a valid Email address.",
),
'isUnique' => array(
'rule' => 'isUnique',
'message' => "This Email is already taken.",
),
),
'user_type' => array(
'inList' => array(
'rule' => array('inList', array('particular','professional','association')),
'required' => false,
'message' => "Your choice is not valid.",
),
),
'denomination' => array(
'maxLength' => array(
'rule' => array('maxLength', 150),
'message' => "Your company name can't contain more than %d characters.",
'on' => 'update',
),
),
'siret' => array(
'maxLength' => array(
'rule' => array('maxLength', 45),
'message' => "Your company registration number can't contain more than %d characters.",
'on' => 'update',
),
),
'phone' => array(
'maxLength' => array(
'rule' => array('maxLength', 20),
'message' => "Your phone number can't contain more than %d characters.",
'on' => 'update',
),
),
'address' => array(
'maxLength' => array(
'rule' => array('maxLength', 255),
'message' => "Your email address can't contain more than %d characters.",
'on' => 'update',
),
),
'zipcode' => array(
'maxLength' => array(
'rule' => array('maxLength', 15),
'message' => "Your zip code can't contain more than %d characters.",
'on' => 'update',
),
),
'city' => array(
'maxLength' => array(
'rule' => array('maxLength', 150),
'message' => "Your city can't contain more than %d characters.",
'on' => 'update',
),
),
'birth' => array(
'maxLength' => array(
'rule' => array('maxLength', 10),
'message' => '%d characters maximum for your date of birth.',
'allowEmpty' => true,
),
),
);
И несколько раз, у меня есть эта ошибка тоже: (если это может помочь)
Fatal Error
Error: Call to undefined method Validation::getDataSource()
File: Z:\wamp\www\gc2\lib\Cake\Model\Datasource\DboSource.php
Line: 1062
Notice: If you want to customize this error message, create app\View\Errors\fatal_error.ctp
Версия CakePHP: 2.4.3 (Извините за мой плохой английский, я французский ^^)
Здравствуйте и спасибо за ответ. Я уже пытаюсь использовать «maxLength», но все равно та же ошибка для всех этих полей «Предупреждение (512): Не удалось найти обработчик проверки maxLength для lastname [CORE \ Cake \ Model \ Validator \ CakeValidationRule.php, строка 281]" – ZoRo
Обновите код в OP, чтобы показать, какие изменения вы внесли. Также убедитесь, что вы очистили свой кеш, чтобы убедиться, что новый код вызывается правильно. –
Код обновлен, и да, я очистил свой кеш. – ZoRo