cakePHP “required” validation
-
01-10-2019 - |
Question
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.
OTHER TIPS
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow