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
It seems to be using a singular version of the relation name instead of the provided field label:
This becomes more of an issue for us when we support multiple languages for example below where the english field label is 'Affiliates' and lets assume another (fake) language this translates to 'Äffïlïätës'.
See below how the validation message is successfully translated also (using our fake language) but the :attribute part is stuck using the english singular version of the relation name.
Same seems to apply to any relations that supports attaching:
MorphToMany
BelongsToMany
etc
Detailed steps to reproduce the issue on a fresh Nova installation:
With the field above
Submit select empty
See that validation message is not using label.
Digging deeper
The issue seems to be ResourceAttachController line 82 is attempting to get an attribute label but at no point resolves the field label and it is passed on line 85 to the Validator property customAttributes via $this->customRulesKeys.
At a minimum it would be acceptable for it to use $resource::singularLabel() here if you are unable to access the field label. However, it seems that PerformsValidation::validationAttachableAttributeFor method is finding the field and then calling getValidationAttribute which does this:
I can't see anywhere in the code where validationAttribute is or can be set? Maybe its dynamically done somewhere.
Anyway, I think as a minimum we should change this to fallback to using the name property before resorting to the attribute.
Description:
It seems to be using a singular version of the relation name instead of the provided field label:
This becomes more of an issue for us when we support multiple languages for example below where the english field label is 'Affiliates' and lets assume another (fake) language this translates to 'Äffïlïätës'.
See below how the validation message is successfully translated also (using our fake language) but the
:attribute
part is stuck using the english singular version of the relation name.Same seems to apply to any relations that supports attaching:
Detailed steps to reproduce the issue on a fresh Nova installation:
Digging deeper
The issue seems to be
ResourceAttachController
line82
is attempting to get an attribute label but at no point resolves the field label and it is passed on line85
to theValidator
propertycustomAttributes
via$this->customRulesKeys
.At a minimum it would be acceptable for it to use
$resource::singularLabel()
here if you are unable to access the field label. However, it seems thatPerformsValidation::validationAttachableAttributeFor
method is finding the field and then callinggetValidationAttribute
which does this:Fix
I can't see anywhere in the code where
validationAttribute
is or can be set? Maybe its dynamically done somewhere.Anyway, I think as a minimum we should change this to fallback to using the
name
property before resorting to theattribute
.Result is the message uses the field label as expected:
The text was updated successfully, but these errors were encountered: