Hi, why do I get ArrayArray as Error Message?
$validator
->notEmptyString('license_id', 'LIC field value is needed', function ($context) {
return isset($context['data']['random']);
})
->add('license_id', 'validFormat', [
'rule' => ['custom', '/^\d+$/'],
'message' => 'License ID must be a number.',
'on' => function ($context) {
return isset($context['data']['random']);
}
]);
return $validator;
with:
echo $this->Form->Error(‘parkalbumsimages.’ . $key . ‘.license_id’);
i get the correct one but i still get ArrayArray and also two Warnings:
[Warning (2) ](javascript:void(0);): Array to string conversion [in /var/www/html/vendor/cakephp/cakephp/src/View/StringTemplate.php, line 256]
if (is_array($replacement)) {
$replacement = implode('', $replacement);
}
[Warning (2) ](javascript:void(0);): Array to string conversion [in /var/www/html/vendor/cakephp/cakephp/src/View/StringTemplate.php, line 256]
if (is_array($replacement)) {
$replacement = implode('', $replacement);
}
any idea?
Is this from the code you had before with debug
calls in it? Or are these warnings happening without any debug
calls in your code?
no a new problem… the other ones are solved!
i guess it has something to do with the fact that it is an array :
i do:
foreach ($FormDataEventc[‘eventalbumsimages’] as $key => $eventalbumsimage) {
and I get the correct Error with:
echo $this->Form->Error(‘eventalbumsimages.’ . $key . ‘.license_id’);
the error that is thrown by itself is wrong because of the array… no idea why… because for body it works fine…
idea?
i get the same problem with:
$validator
->requirePresence('license_id', function ($context) {
return isset($context['data']['random']);
})
->add('license_id', 'validFormat', [
'rule' => ['custom', '/^\d+$/'],
'message' => 'License ID must be a number.',
'on' => function ($context) {
return isset($context['data']['random']);
}
]);
is probably replacement is an array but you use implode to convert it to string?
no I dont do anything special: in a form that would require: echo $this->Form->Error(‘images.’ . $key . ‘.license_id’); it throws the warnings and ArrayArray…
but the same validation rule will work fine for this: echo $this->Form->Error(‘license_id’);