You are here

public static function DateRecurModularAlphaWidget::afterBuildModularWidget in Recurring Date Field Modular Widgets 8

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldWidget/DateRecurModularAlphaWidget.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularAlphaWidget::afterBuildModularWidget()
  2. 2.x src/Plugin/Field/FieldWidget/DateRecurModularAlphaWidget.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularAlphaWidget::afterBuildModularWidget()

After build callback for the widget.

Parameters

array $element: The element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The element.

File

src/Plugin/Field/FieldWidget/DateRecurModularAlphaWidget.php, line 325

Class

DateRecurModularAlphaWidget
Date recur alpha widget.

Namespace

Drupal\date_recur_modular\Plugin\Field\FieldWidget

Code

public static function afterBuildModularWidget(array $element, FormStateInterface $form_state) {

  // Wait until ID is created, and after
  // \Drupal\Core\Render\Element\Checkboxes::processCheckboxes is run so
  // states are not replicated to children.
  $weekdaysId = $element['weekdays']['#id'];
  $element['ordinals']['#states']['visible'][0]['#' . $weekdaysId . ' input[type="checkbox"]'] = [
    'checked' => TRUE,
  ];

  // Add container classes to compact checkboxes.
  $element['weekdays']['#attributes']['class'][] = 'container-inline';
  $element['ordinals']['#attributes']['class'][] = 'container-inline';
  return $element;
}