You are here

public function DateRecurModularSierraWidget::openTheModal in Recurring Date Field Modular Widgets 8

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

Callback to convert RRULE data from form to modal then open modal.

File

src/Plugin/Field/FieldWidget/DateRecurModularSierraWidget.php, line 718

Class

DateRecurModularSierraWidget
Date recur sierra widget.

Namespace

Drupal\date_recur_modular\Plugin\Field\FieldWidget

Code

public function openTheModal(array &$form, FormStateInterface $form_state) {
  $button = $form_state
    ->getTriggeringElement();
  $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -2));
  $this
    ->transferStateToTempstore($element, $form_state);

  // Open modal.
  $content = $this->formBuilder
    ->getForm(DateRecurModularSierraModalForm::class);
  $content['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $dialogOptions = [
    'width' => '575',
  ];
  return (new AjaxResponse())
    ->setAttachments($content['#attached'])
    ->addCommand(new OpenModalDialogCommand($this
    ->t('Custom recurrence'), $content, $dialogOptions));
}