Add conditional field layouts support to Preparse field type #94
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
getElementConditionRuleType
function to thePreparseFieldType
class.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
TextFieldConditionRule
will be returned. At the moment it will provide support forDateFieldConditionRule
,NumberFieldConditionRule
andTextFieldConditionRule
.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!