cakePHP "required" validation
is there any mistake in this validation???
var $validate = array(
'brand_id' => a开发者_StackOverflowrray(
'required' => array(true),
'message' => array('select a brand'),
)
);
brand_id is a select box
It show error as "message" instead of "select a brand" if the message is not in array it shows errorWarning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2571]
using cakePHP 1.3
You're missing a rule, just required
won't do. Use 'notEmpty'
as rule if that's what you want. Also, required
and message
should (must?) not be arrays.
Why do you have arrays everywhere?
var $validate = array(
'brand_id' => array(
'required' => true,
'message' => 'select a brand',
)
);
Refer to: http://book.cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Data-Validation.html
精彩评论