Search code examples
cakephpvalidationrequiredfieldvalidatorcakephp-1.3

cakePHP "required" validation


is there any mistake in this validation???

 var $validate = array(
  'brand_id' => array(
   '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 error

Warning (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


Solution

  • 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.