fix: Add support for dependsOn inside flexible content fields#547
Open
iamgerwin wants to merge 1 commit intowhitecube:masterfrom
Open
fix: Add support for dependsOn inside flexible content fields#547iamgerwin wants to merge 1 commit intowhitecube:masterfrom
iamgerwin wants to merge 1 commit intowhitecube:masterfrom
Conversation
This commit adds a new middleware (InterceptFlexibleDependsOnAttributes) that transforms flexible content field names in dependsOn requests by stripping the group key prefix. This allows the dependsOn callbacks to receive the original field names they expect. The middleware intercepts Nova's creation-fields and update-fields API requests and: - Transforms the 'field' query parameter by removing the group prefix - Transforms input field names by removing the group prefix This fixes the issue where dependsOn callbacks inside flexible layouts receive prefixed field names (e.g., 'ckOi67sYIRR0L6kh__product') instead of the expected original names (e.g., 'product'). Fixes whitecube#524
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.
Summary
This PR adds proper support for Nova's
dependsOnfunctionality inside flexible content layouts by introducing a new middleware that transforms field names in dependent field requests.Problem
When using
dependsOnon fields inside a Flexible layout, the callbacks don't receive the expected field names. This is because:ckOi67sYIRR0L6kh__product)creation-fieldsorupdate-fieldsendpoints for dependent fields, it sends these prefixed namesdependsOncallback expects the original field names (e.g.,product)Solution
Added a new middleware
InterceptFlexibleDependsOnAttributesthat:creation-fieldsandupdate-fields)fieldquery parameter by stripping the group prefixThis allows the
dependsOncallbacks to work correctly inside flexible layouts.Usage Example
Files Changed
src/Http/Middleware/InterceptFlexibleDependsOnAttributes.php- New middleware for handling dependsOn requestssrc/FieldServiceProvider.php- Register the new middlewareTechnical Details
The middleware uses the existing
FlexibleAttribute::GROUP_SEPARATORconstant (__) to detect and strip group prefixes from field names. It only processes requests that match Nova's dependent field API routes.Fixes #524