[5.x] Fix group fieldtype child field validation rules when using {this} within a replicator/grid #11931
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
groupfieldtype currently has its context set using:Which is fine when group is used outside of a replicator.
However, if you use a group within a replicator/grid, validation rules of the child fields of the group fail to run correctly.
For example, this Blueprint (you can put this in a clean install in the Pages collection):
Within the Replicator, there is a Group. Within the Group is a Select field that changes the validation behaviour of the Text Field.
The issue is that the
{this}is not being correctly handled.The validation rules that are generated for this Blueprint are:
Notice the rules for
my_text_fieldare wrong:exclude_unless:my_group.my_group.change_validation,YesThis is incorrect:
my_grouphandle as the contextmy_replicatorThe expected rule is:
exclude_unless:my_replicator.0.my_group.change_validation,YesThis PR uses the same logic from the replicator/grid fieldtypes to correctly allow child fields within a group within a replicator to have the correct rules applied.
If you were to create a new Entry with the above Blueprint, add two items, the rules generated will correctly become: