public function DateRecurModularWidgetBase::massageFormValues in Recurring Date Field Modular Widgets 3.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/DateRecurModularWidgetBase.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularWidgetBase::massageFormValues()
- 2.x src/Plugin/Field/FieldWidget/DateRecurModularWidgetBase.php \Drupal\date_recur_modular\Plugin\Field\FieldWidget\DateRecurModularWidgetBase::massageFormValues()
Massages the form values into the format expected for field values.
Parameters
array $values: The submitted form values produced by the widget.
- If the widget does not manage multiple values itself, the array holds the values generated by the multiple copies of the $element generated by the formElement() method, keyed by delta.
- If the widget manages multiple values, the array holds the values of the form element generated by the formElement() method.
array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array An array of field values, keyed by delta.
Overrides WidgetBase::massageFormValues
1 call to DateRecurModularWidgetBase::massageFormValues()
- DateRecurModularAlphaWidget::massageFormValues in src/
Plugin/ Field/ FieldWidget/ DateRecurModularAlphaWidget.php - Massages the form values into the format expected for field values.
3 methods override DateRecurModularWidgetBase::massageFormValues()
- DateRecurModularAlphaWidget::massageFormValues in src/
Plugin/ Field/ FieldWidget/ DateRecurModularAlphaWidget.php - Massages the form values into the format expected for field values.
- DateRecurModularOscarWidget::massageFormValues in src/
Plugin/ Field/ FieldWidget/ DateRecurModularOscarWidget.php - Massages the form values into the format expected for field values.
- DateRecurModularSierraWidget::massageFormValues in src/
Plugin/ Field/ FieldWidget/ DateRecurModularSierraWidget.php - Massages the form values into the format expected for field values.
File
- src/
Plugin/ Field/ FieldWidget/ DateRecurModularWidgetBase.php, line 92
Class
- DateRecurModularWidgetBase
- Date recur modular widget base.
Namespace
Drupal\date_recur_modular\Plugin\Field\FieldWidgetCode
public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
foreach ($values as $delta => &$value) {
// If each of start/end/time-zone contain invalid values, quit here.
// Validation errors will show on form. Notably start and end day are
// malformed arrays thanks to 'datetime' element.
/** @var \Drupal\Core\Datetime\DrupalDateTime|array|null $start */
$start = $value['start'] ?? NULL;
/** @var \Drupal\Core\Datetime\DrupalDateTime|array|null $end */
$end = $value['end'] ?? NULL;
$timeZone = $value['time_zone'] ?? NULL;
$mode = $value['mode'] ?? NULL;
if (!$start instanceof DrupalDateTime || !$end instanceof DrupalDateTime || !is_string($timeZone) || !is_string($mode)) {
$value = [];
}
}
return $values;
}