-
Notifications
You must be signed in to change notification settings - Fork 684
Description
Created by: Mats Mikkel Rummelhoff (mail@mmikkel.no) on 2015/03/09 00:12:31 +0000
Votes at time of UserVoice import: 355
Coming from Wordpress and ACF, I miss being able to set up simple conditionals for fields.
An example scenario:
A field layout for the section "Albums" includes a true/false called "Compilation". If unchecked, the layout displays a text input field called "Artist name". If checked, the "Artist" field is hidden and replaced by a Table field called "Artists", where the author is able to enter any number of artists featured on the album.
In ACF, all fieldtypes has a "Conditional logic" checkbox. If checked, the field creator is able to build their conditions for showing or hiding the field, based on any selectable (as in checkbox, radio buttons, dropdowns, true/false etc) "sibling" fields in the same Field Group (or Layout, as it were). You can also apply conditionals to fields inside Repeaters (ACF's version of the Table field) and Flexible Content (Matrix) fields, which works the same way – the conditonal builder UI relies on selectable "sibling" fields in the current context.
In the example scenario, the condition for showing the "Artist" field would be [IF "Compilation" IS NOT EQUAL TO "checked"], and for the "Artists" field it would be the opposite.
Conditionals are not super important in Craft, as we have Entry Types, but I can definitely see use cases where one would be more elegant than the other, and I'm often encountering situations where creating a whole separate entry type just to be able to offer a small amount of flexiblity in the layout just seems a bit overkill. If Craft had conditionals, I'd use Entry Types only when the field layout would be more different than similar across various content types in the same section.
To close, one huge difference between Craft and ACF is obviously that fields in Craft are shared between layouts, whereas fields in ACF are tightly coupled to their group. This means that any conditional logic in Craft would probably have to be applied in the Layout Designer (possibly by adding a "Conditional logic" button to the fields' cogwheel/settings button, which could then load up a conditionals builder in a modal or whatever) and not when creating any individual field.
For Matrix fields, however, it would make sense to be able to add conditionals across block types and their fields in a more similar manner to the ACF way.