Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional field layouts support to Preparse field type #94

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

wblommaert
Copy link

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 the PreparseFieldType 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 for DateFieldConditionRule, NumberFieldConditionRule and TextFieldConditionRule.

An example use case (ours in this case) is:

  • We have authors that administrate one page via the control panel
  • Depending on whether the author has a paid plan, certain fields will be hidden or shown
  • We preparse a number value on the page entry by using the user's payment details
  • We use the preparsed 1 or 0 value to show or hide specific fields that can only be accessed when you're a paid user

I'd be more than happy to hear and apply any feedback or questions you might have!

This enables the preparse field to be used as part of the conditional field layouts in Craft CMS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant