protected function SmartDateOverrideForm::override in Smart Date 8.2
Same name and namespace in other branches
- 3.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
- 3.0.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
- 3.1.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
- 3.2.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
- 3.3.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
- 3.4.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::override()
Create or updating an override entity, this means overriding one rule item.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The provided form values.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to SmartDateOverrideForm::override()
- SmartDateOverrideForm::submitForm in modules/
smart_date_recur/ src/ Form/ SmartDateOverrideForm.php - Form submission handler.
File
- modules/
smart_date_recur/ src/ Form/ SmartDateOverrideForm.php, line 185
Class
- SmartDateOverrideForm
- Form controller for Smart Date Recur instace override edit forms.
Namespace
Drupal\smart_date_recur\FormCode
protected function override(FormStateInterface $form_state) {
if (!empty($form_state
->getValue('oid'))) {
// Existing override, so retrieve and update values.
$override = SmartDateOverride::load($form_state
->getValue('oid'));
// Only the values, end_value, and duration are changeable.
$override
->set('value', $form_state
->getValue('value')
->getTimestamp());
$override
->set('end_value', $form_state
->getValue('end_value')
->getTimestamp());
$override
->set('duration', $form_state
->getValue('duration'));
}
else {
$values = [
'rrule' => $form_state
->getValue('rrule'),
'rrule_index' => $form_state
->getValue('rrule_index'),
'value' => $form_state
->getValue('value')
->getTimestamp(),
'end_value' => $form_state
->getValue('end_value')
->getTimestamp(),
'duration' => $form_state
->getValue('duration'),
];
// New override, so construct object.
$override = SmartDateOverride::create($values);
}
$override
->save();
}