-
Notifications
You must be signed in to change notification settings - Fork 824
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
FIX/API Always set polymorphic class name in gridfield on new records. #10297
FIX/API Always set polymorphic class name in gridfield on new records. #10297
Conversation
95ede91
to
faacbd9
Compare
43a4446
to
db4153e
Compare
I thought I submitted a PR for this in past, but could've been related to polymorphic has_one, not has_many. Unrelated — I don't think we support two change types in the commit message such as FIX/API or ENH/DOC for automatic changelog creation, so you need to choose one or split the commit into two. |
There are two commits, one for each the API and the FIX. I don't think the PR name itself will affect the changelog. |
db4153e
to
cd3573f
Compare
True, the issue name has no role in that, forgot to check the list of actual commits. All good. |
/** | ||
* Gets the field name which holds the related object class. | ||
*/ | ||
public function getForeignClassKey(): string |
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.
Can we add an explicit test for this method?
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.
Sure thing
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.
Test added.
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.
Looks good ... I would like to see an explicit test to cover that new method.
@sabina-talipova Can you confirm that you've manually tested that this PR fixes the user form issue?
I've done test in my local environment. Manual tests - PASSED (NO ERROR or misbehaving), phpUnit tests in local - PASSED. Should I run other tests as well? |
cd3573f
to
5436df5
Compare
@maxime-rainville I've added the test you requested. |
When creating a new record in a gridfield item edit form and polymorphic
has_one
relations have the ID set, but not the class. In polymorphic relations the ID is useless without the class.This has caused at least one known issue (see parent issue below) where a relation is relied on for canX permissions but ultimately the relation only exists after the record has been created.
Parent issue