Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you add a token tree table to a form and use #states to hide / show them then this doesn't work because the table does not have a js-form-item class.
When you do this in your form then it does work:
$element['token_tree'] = \Drupal::service('token.tree_builder')->buildRenderable($entity_types, ['global_types' => FALSE]);
$element['token_tree']['#attributes']['class'][] = 'js-form-item';
Is there a reason why the token tree table does not have the form-item and js-form-item class?
Comments
Comment #2
Dave ReidBecause it's not a form item? If you need to use #states I would suggest putting the token tree inside of a container element.