Field group #states interferes with children #states

Created on 6 February 2023, over 1 year ago
Updated 5 October 2023, 9 months ago

Problem/Motivation

It seems that adding a dependency to a field group that affects its visibility seems to interfere with the dependencies of the field group children.

Steps to reproduce

- Create a control field and field group that contains a selection of text fields
- Add a dependency where the control field affects the visibility of the field group
- Add a dependency on the first child field where the control field affects its required state.
- When the control field makes the group become visible, all child fields are marked as required.
- If you change the field group dependency is changed from Visible to Unchanged only the correct field is marked as required when using the control field.

πŸ› Bug report
Status

Active

Version

3.4

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom very_random_man

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @very_random_man
  • πŸ‡¬πŸ‡§United Kingdom very_random_man

    Actually, I think this is more likely a Field Group issue as it still happens if I remove the Conditional Fields dependencies and use various form hooks to apply #states directly.

    Some more detail:
    - I have field group tabs and inside one of those I have a checkboxes element and a fieldset containing text fields.
    - I have used hook_form_alter to add #states to make one of the text fields required depending on a checkbox value.
    - I have used hook_field_group_form_process_alter (and a tried bunch of other similar hooks) to add #states to make the fieldset visible depending on the same checkbox value as per https://www.drupal.org/project/field_group/issues/1053174#comment-14138494 πŸ’¬ hook_form_alter form state problems Closed: works as designed

    What happens is that when there is a #states value on the fieldset, the required state is applied to all the text fields inside it.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    I have used Conditional Fields module to make a field group visible (or not) and can confirm that once the FGis made visible; all the fields within it are made required. The red star even shows on the label for the FG itself.

Production build 0.69.0 2024