[4.x] Add PHP fieldPathPrefix method - #9080
Merged
Merged
Conversation
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Vue fieldtype components have a
fieldPathPrefixprop which contains a dot notation version of the field handles/set indexes. This tells fields exactly where they are in the structure and is needed to access the values of sibling set fields in the store.PHP fieldtype classes do not have an equivalent, which means it’s not currently possible to get the values of sibling set fields in
process/preloadetc. Currently they can only access:$this->field->parent()which returns the root entry$this->field->parentField()which returns the replicator/bard field$this->field->handlePath()which returns an array of the field handles but excludes the set indexesThis PR adds a
Field::fieldPathPrefix()method that returns a dot notation path just like Vue. It also adds afieldPathKeys()method that returns the same data as an array. And for completeness afieldPathKeysmethod has also been added to the Vue fieldtype components.To make it work I’ve had to update a few other classes in order to ensure the index is always passed down. If people are extending replicator/grid and overriding the
processRow()method this could be breaking as there's now a new index argument, so it might need to target v5.There are two situations where an index doesn't exist and therefore the
fieldPathPrefixwon’t be complete/real:NestedFields::preProcessConfig()method the field has no knowledge of it's parents so the path is just a single field handle$defaultsand$newlookups in bard/replicatorpreload()methods the field has knowledge of its parents but it’s not being used for a real set so the index will be-1