public function SmartDateDefaultWidget::settingsForm in Smart Date 3.1.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.0.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.2.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.3.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.4.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form definition for the widget settings.
Overrides SmartDateWidgetBase::settingsForm
1 call to SmartDateDefaultWidget::settingsForm()
- SmartDateTimezoneWidget::settingsForm in src/
Plugin/ Field/ FieldWidget/ SmartDateTimezoneWidget.php - Returns a form to configure settings for the widget.
1 method overrides SmartDateDefaultWidget::settingsForm()
- SmartDateTimezoneWidget::settingsForm in src/
Plugin/ Field/ FieldWidget/ SmartDateTimezoneWidget.php - Returns a form to configure settings for the widget.
File
- src/
Plugin/ Field/ FieldWidget/ SmartDateDefaultWidget.php, line 48
Class
- SmartDateDefaultWidget
- Plugin implementation of the 'smartdate_default' widget.
Namespace
Drupal\smart_date\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$field_def = $this->fieldDefinition;
$field_type = $field_def
->getType();
if ($field_type == 'daterange') {
// For core fields, add the option to configure allowed durations.
$defaults = [];
$default_duration = $this
->getSetting('default_duration');
if ($default_duration || $default_duration === 0 || $default_duration === '0') {
$defaults['default_duration'] = $default_duration;
}
$default_duration_increments = $this
->getSetting('default_duration_increments');
if ($default_duration_increments) {
$defaults['default_duration_increments'] = $default_duration_increments;
}
SmartDateFieldItemList::addDurationConfig($element, $defaults);
}
return $element;
}