-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LabelPrefix context to better guess correct input labels #7710
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SimpleFormIteratorItem should set a prefix as well if I understand correctly, shouldn't it?
No, ArrayInput doesn't change the LabelPrefix, as developers will prefer to have the entire path in the message. For instance: const PostEdit = () => (
<Edit>
<SimpleForm>
<ArrayInput source="backlinks">
<SimpleFormIterator>
<TextInput source="url" />
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a linter warning left, otherwise 💪
Fixes #7646
Instead of using the
resource
, the function that builds field and input labels can use the value of a context, which is set by the forms. This allows for better defaults in forms when using<ReferenceInput>
and<ArrayInput>
.The change is made BC by keeping the previous behavior when the
resource
is passed explicitly.I also took the opportunity to fix default input labels in
<SimpleFormIterator>
children (instead ofresources.posts.fields.aothors.123.name
, they are nowresources.posts.fields.aothors.name
).