Conditional Fields
Content fields and groups visibility based on the values of user defined "controlling" fields.
Overview
The Conditional Fields module allows set fields with allowed values as "controlling fields" for other fields and groups. When a field or group is "controlled", it will only be available for editing and displayed if the selected values of the controlling field match the "trigger values" assigned to it. You can, for example, make a custom "article teaser" field that is shown only if a "Has teaser" checkbox is checked.
When editing a node, the controlled fields are dynamically shown and hidden with javascript.
On node view, the controlled fields which were left untriggered are hidden.
Dependencies
- Drupal core: 6.x or 5.x (note that the 5.x branch of Conditional Fields is very outdated, while the 6.x branch is actively maintained).
- Content Construction Kit (tested up to version 2.2) -> http://drupal.org/project/cck.
- OPTIONAL: Fieldgroups (included in CCK) > If enabled you can also set groups as controlled fields.
Installation
- Copy the unpacked folder "conditional_fields" in your modules folder (usually [base_path]/sites/all/module).
- Go to the modules administration page (admin/build/modules) and activate the module (you will find it in the "CCK" package)
- Assign the "Administer conditional fields" permission to the desired user roles.
Usage
Field configuration
Once the module is activated, a new set of options will appear in the editing form of cck fields, from where you can select which of the allowed values available of candidate "controlling" fields will make the field "controlled". If - Not controlling - or no value is selected, the field will be shown as usual.
These are the requisites to make a field controllable:
- The controlling field widget must be single or multiple select list, radio buttons or checkboxes.
- The controlling field must have allowed values.
- If the controlled field is in a group, the controlling field must be in the same group.
- If you want to make a group controllable, the controlling field should not be inside a group.
Example:
- Field A
- Group B
- Field C
- Field D
- Group E
- Field F
- Field GWe assume that A, C, and F have allowed values and are select lists, radio buttons, or checkboxes. D and G are a text fields with no allowed values.
A can control B, E and G.
C can control D.
All other combinations are not supported by conditional fields at this time.
Content type settings
There is a "Conditional fields" tab in every content type admin page with the following options:
- User Interface options.
- Javascript: You can decide if you want to use javascript to dynamically disable (grey out) or hide the fields when editing a node.
- Animation: There are three animations currently available: show/hide (default), slide down/slide up, and fade in/fade out. You can also set the speed of the animation.
- Orphaned controlled fields settings.
These settings control the visibility (on node view) and editability (on node edit) of controlled fields when the controlling fields are not visible (e.g.: set to 'Hidden' in the fields display settings) or not editable (e.g.: by an access control module). - Reset untriggered fields to default values.
When unchecked, untriggered controlled fields are not reset to their default values when saving a node. - Administrators see all fields.
If checked, users with 'administer conditional fields' permission will see all controlled fields of a node, even if the weren't triggered. - Reset.
If checked, all conditional fields configurations for this content type will be reset (though the fields themselves will remain untouched).
Known bugs and incompatibilities
- Each field or group can be controlled from only one field (though a field can control any number of fields and groups). This is a bug, and will be corrected in later development.
- Conditional Fields, for now, supports only core CCK fields and widgets. Fields from other modules might work, but probably won't. There are confirmed incompatibilities with the following modules:
- tinyMCE
- Multigroup
- date
- Content Taxonomy
Check the issue queue for more information:
