Одно правило на одно поле
This definition technique allows for better control of how the validation rules work. But before we discuss that, let’s see the general usage pattern adding a rule for a single field:
Простой текстvar $validate = array('fieldName1' => array('rule' => 'ruleName', // or: array('ruleName', 'param1', 'param2' ...)'required' => true,'allowEmpty' => false,'on' => 'create', // or: 'update''message' => 'Your Error Message'));
The 'rule' key is required. If you only set 'required' => true, the form validation will not function correctly. This is because 'required' is not actually a rule.
As you can see here, each field (only one field shown above) is associated with an array that contains five keys: ‘rule’, ‘required’, ‘allowEmpty’, ‘on’ and ‘message’. Let’s have a closer look at these keys.


Коментарии:
Добавить коментарий