using cakephp 2.0 rc3.
following validation in my model:
var $validate = array(
'loginname' => array(
'minCharactersRule' => array(
'rule' => array('minLength', 3),
),
'alphaNumericRule' => array(
'rule' => 'alphaNumeric',
),
'uniqueRule' => array(
'rule' => 'isUnique',
),
'on' => 'create',
'required' => true,
'allowEmpty' => false,
),
'password' => array(
'minCharactersRule' => array(
'rule' => array('minLength', 5),
),
'required' => true,
'allowEmpty' => false,
),
'email' => array(
'emailRule' => array(
'rule' => array('email'),
),
'uniqueRule' => array(
'rule' => 'isUnique',
),
'required' => true,
'allowEmtpy' => false,
),
'display_name' => array(
'betweenRule' => array(
'rule' => array('between', 3, 20),
),
'uniqueRule' => array(
'rule' => 'isUnique',
),
'required' => true,
'allowEmpty' => false,
),
'registered' => array(
'rule' => array('date', 'ymd'),
'required' => false,
'allowEmpty' => false,
'on' => 'create'
),
'status' => array(
'rule' => 'numeric',
'required' => false,
'allowEmpty' => false,
'on' => 'create'
),
);
when i fill out every field and submit im getting “required” error messages…
debug($this->Model->validationErrors) says:
Array(
[loginname] => Array
(
[0] => required
)
[password] => Array
(
[0] => required
)
[email] => Array
(
[0] => required
)
[display_name] => Array
(
[0] => required
))
in addition some ugly warnings appear:
Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/Cake/Model/Model.php, line 2981]
(4 times)
when i saw it the first time, i thought i misstyped anything, but after checking 3-4 times and getting the same error, i decided to come here to ask 😡
am i missing anything? running out of ideas …
nahri
after reading the cookbook examples again, i found the solution.
every single rule must have the required, allowEmpty, etc, parameters given, not the field itself.
this makes no sense to me, but thats how it is described in the manual and how it works..