Ability to use conditional status in a custom composite field

Created on 21 December 2023, 11 months ago
Updated 9 September 2024, 2 months ago

I'd like to be able to use conditional states to show and hide fields within a custom composite that allows unlimited values. This works for the first one but obviously, I need a way to replace the index with the correct rows index.

states:
  required:
    ':input[name="applicants[items][1][_item_][affirmation]"]':
      value: 'Yes'
  invisible:
    ':input[name="applicants[items][1][_item_][affirmation]"]':
      '!value': 'Yes'
✨ Feature request
Status

Closed: won't fix

Version

6.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jphelan

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

Comments & Activities

  • Issue created by @jphelan
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦
  • Status changed to Closed: won't fix 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Conditional logic for composite elements should be implemented in custom code. There are examples in webform_example_composite.module.

    If we allow set #states for composite sub-elements via the UI, we must also sort out backend conditional validation.

  • πŸ‡©πŸ‡ͺGermany demonde

    As far as I can see, there is no example for conditional logic for composite elements in webform_example_composite.module.

    Either I did not find it in the module code or it is not there.

  • Check WebformExampleComposite.php, afterBuild method.

  • πŸ‡©πŸ‡ͺGermany demonde

    Thanks.

    So it is public static function afterBuild in webform/modules/webform_example_composite/src/Element/WebformExampleComposite.php which allows to define statest.

Production build 0.71.5 2024