public function DateRecurModularSierraWidget::openOccurrencesModal in Recurring Date Field Modular Widgets 8
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldWidget/DateRecurModularSierraWidget.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularSierraWidget::openOccurrencesModal()
- 2.x src/Plugin/Field/FieldWidget/DateRecurModularSierraWidget.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularSierraWidget::openOccurrencesModal()
Callback to convert RRULE data from form to modal then open modal.
File
- src/
Plugin/ Field/ FieldWidget/ DateRecurModularSierraWidget.php, line 735
Class
- DateRecurModularSierraWidget
- Date recur sierra widget.
Namespace
Drupal\date_recur_modular\Plugin\Field\FieldWidgetCode
public function openOccurrencesModal(array &$form, FormStateInterface $form_state) {
$button = $form_state
->getTriggeringElement();
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
$this
->transferStateToTempstore($element, $form_state);
// Open modal.
$content = $this->formBuilder
->getForm(DateRecurModularSierraModalOccurrencesForm::class);
$content['#attached']['library'][] = 'core/drupal.dialog.ajax';
$dialogOptions = [
'width' => '575',
];
return (new AjaxResponse())
->setAttachments($content['#attached'])
->addCommand(new OpenModalDialogCommand($this
->t('Occurrences'), $content, $dialogOptions));
}