CakePHP 3 validation params -
is right in cakephp 3?
$validator ->add('fieldname', [ 'rulename' => [ 'rule' => 'isunique', 'required' => true, 'allowempty' => null, 'on' => null, 'last' => false, 'message' => null ] ]);
or should in following way
$validator ->requirepresence('fieldname') ->notempty('fieldname', 'this field required') ->add('fieldname', [ 'rulename' => [ 'rule' => 'isunique', 'on' => null, 'last' => false, 'message' => 'this field required', ] ])
i need know if both forms correct. or right way , why?
try this, generate cake
public function validationdefault(validator $validator) { $validator ->integer('id') ->allowempty('id', 'create'); $validator ->requirepresence('name', 'create') ->notempty('name') return $validator; }
Comments
Post a Comment