Add conditional field layouts support to Preparse field type#94
Open
wblommaert wants to merge 1 commit intojalendport:developfrom
Open
Add conditional field layouts support to Preparse field type#94wblommaert wants to merge 1 commit intojalendport:developfrom
wblommaert wants to merge 1 commit intojalendport:developfrom
Conversation
This enables the preparse field to be used as part of the conditional field layouts in Craft CMS.
|
Hi @jalendport, we'd also benefit from having this available in an upcoming project. Any plans to implement this? I'm gonna start with a fork with the above changes, so can also provide feedback (if it works well in Craft 5). |
|
Can confirm in first tests, this works 👌 |
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.
Recently we were trying to use some of our Preparse field values as conditionals to show and hide other fields in our field layouts but realised this isn't possible at the moment. This PR enables the Preparse field values to be used as part of the conditional field layouts in Craft CMS by adding the
getElementConditionRuleTypefunction to thePreparseFieldTypeclass.To account for the different underlying column types that Preparse offers, the function will automatically check for the used column type and return the corresponding, existing field condition rule that Craft CMS already provides. In case this ever gets expanded on, the default
TextFieldConditionRulewill be returned. At the moment it will provide support forDateFieldConditionRule,NumberFieldConditionRuleandTextFieldConditionRule.An example use case (ours in this case) is:
I'd be more than happy to hear and apply any feedback or questions you might have!