jordankaiser
9/12/2019 - 3:36 PM

Conditionally Hide Field Group

Conditionally Hide Field Group

/**
 * Implements hook_field_group_form_process_build_alter().
 * Alter the form after all groups are processed.
 *
 * @param array $element
 *   The element being processed.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   The form state
 * @param $complete_form
 *   The complete form.
 */
function hook_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state, &$complete_form) {
  $element['group_location_details_reference']['#states'] = [
    'visible' => [
      'select[name="field_event_location_type"]' => ['value' => 'existing'],
    ],
  ];
}