Hi, why is the validationAddb not getting into function ($context) { ?
public function validationAddb(Validator $validator): Validator { $validator->requirePresence('license_id', function ($context) { // Confirm the closure is executed and print the context debug('Inside requirePresence closure'); debug($context); if (isset($context['data']['action']) && $context['data']['action'] === 'submit') { return true; } return false; })-; // Add more validation rules as needed return $validator;
parkalbumimage = $this->Parks->Parkalbums->Parkalbumsimages->newEmptyEntity();
…
parkalbumimage = $this->Parks->Parksalbums->Parkalbumsimages->patchEntity($parkalbumimage, $requestData, [‘validate’ => ‘addb’]);
the data inside $requestdata is:
APP/Controller/ParksController.php (line 1218)
object(App\Model\Entity\Parkalbumsimage) id:0 {
‘action’ => ‘submit’
‘[new]’ => true
‘[accessible]’ => [
‘action’ => true,
‘license_id’ => true,
]
‘[dirty]’ => [
‘action’ => true,
]
‘[original]’ => [
]
‘[originalFields]’ => [
]
‘[virtual]’ => [
]
‘[hasErrors]’ => false
‘[errors]’ => [
]
‘[invalid]’ => [
]
‘[repository]’ => ‘Parkalbumsimages’
action is submit and no license_id was providede but he does not give any complaints… btw how can i say that -
add(‘license_id’, ‘validFormat’, [
‘rule’ => [‘custom’, ‘/^\d+$/’],
‘message’ => ‘License ID must be a number.’
])->minLength(‘license_id’, 1); should also be true in the case of action = submit?
any idea ?
right now i never see any result of the two debugs…
best, herzi