public function DateRecurModularSierraWidget::transferModalToFormStateCallback 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::transferModalToFormStateCallback()
- 2.x src/Plugin/Field/FieldWidget/DateRecurModularSierraWidget.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularSierraWidget::transferModalToFormStateCallback()
Callback to convert RRULE data from modal to be consumed by form.
File
- src/
Plugin/ Field/ FieldWidget/ DateRecurModularSierraWidget.php, line 784
Class
- DateRecurModularSierraWidget
- Date recur sierra widget.
Namespace
Drupal\date_recur_modular\Plugin\Field\FieldWidgetCode
public function transferModalToFormStateCallback(array &$form, FormStateInterface $form_state) {
$collection = $this->tempStoreFactory
->get(static::COLLECTION_MODAL_STATE);
$fieldPath = $collection
->get(static::COLLECTION_MODAL_STATE_PATH);
if ($fieldPath) {
$customRrule = $collection
->get(static::COLLECTION_MODAL_STATE_KEY);
if (isset($customRrule)) {
$form_state
->set([
static::FORM_STATE_RRULE_KEY,
$fieldPath,
], $customRrule);
$collection
->delete(static::COLLECTION_MODAL_STATE_KEY);
}
[
$fieldName,
$delta,
] = explode('/', $fieldPath);
$input =& $form_state
->getUserInput();
// After closing modal, switch dropdown to custom setting.
$input[$fieldName][$delta]['recurrence_option'] = 'custom';
}
$form_state
->setRebuild();
}