You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to validate the entire group of fields because the validation condition for the field "Related field" depends on the option selected by the user in "Whatever" field.
This is the extract Nova Resource definition of the field inside "fields" function.
class MyCustomRule implements Rule
{
public function passes($attribute, $value): bool
{
// Validation login. Returns false if error. Adds every error to an array: [ 0 => [ 'field_id' => 'Error message' ], 1 => [ 'field_id' => 'Error message' ], ..., n => [ 'field_id' => 'Error message' ] ]
}
public function message()
{
$messages = [];
foreach ($this->errors as $layoutIndex => $fieldErrors) {
foreach ($fieldErrors as $field => $error) {
$messages[sprintf('groud_id.%d.attributes.%s', $layoutIndex, $field)] = $error;
}
}
return $messages;
}
}
I'm trying to return the errors as:
group_id.0.attributes.field_id: ERROR MESSAGE
group_id.2.attributes.other_unrelated_field: OTHER ERROR MESSAGE
Because I want to display the error below the field with errors. If I dump the $message variable the array structure seems to be as defined, but the response of the request is something like:
{"message":"The given data was invalid.","errors":{"group_id":["ERROR MESSAGE"]}}
I'm not sure how to display errors using Flexible. Can anybody help me? I'm trying to find it in the documentation but I cannot (I'm using Laravel 8 with al older version of Nova v.3 [and I cannot upgrade]).
The error is displayed under the entire Flexible block and not below input field with errors.
The text was updated successfully, but these errors were encountered:
I'm trying to validate the entire group of fields because the validation condition for the field "Related field" depends on the option selected by the user in "Whatever" field.
This is the extract Nova Resource definition of the field inside "fields" function.
And here is MyCustomRule class:
I'm trying to return the errors as:
group_id.0.attributes.field_id: ERROR MESSAGE
group_id.2.attributes.other_unrelated_field: OTHER ERROR MESSAGE
Because I want to display the error below the field with errors. If I dump the $message variable the array structure seems to be as defined, but the response of the request is something like:
I'm not sure how to display errors using Flexible. Can anybody help me? I'm trying to find it in the documentation but I cannot (I'm using Laravel 8 with al older version of Nova v.3 [and I cannot upgrade]).
The error is displayed under the entire Flexible block and not below input field with errors.
The text was updated successfully, but these errors were encountered: