public function SmartDateDefaultWidget::settingsForm in Smart Date 3.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.0.x src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget::settingsForm()
- 3.1.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 WidgetBase::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();
$allow_recurring = FALSE;
if ($field_type == 'smartdate') {
if ($field_def instanceof BaseFieldDefinition) {
// TODO: Document that for custom entities, you must enable recurring
// functionality by adding ->setSetting('allow_recurring', TRUE)
// to your field definition.
$allow_recurring = $field_def
->getSetting('allow_recurring');
}
else {
$allow_recurring = $field_def
->getThirdPartySetting('smart_date_recur', 'allow_recurring');
}
if ($allow_recurring) {
$element['modal'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use modal for managing instances'),
'#default_value' => $this
->getSetting('modal'),
];
}
}
else {
// For core fields, add the option to configure allowed durations.
$defaults = [];
$default_duration = $this
->getSetting('default_duration');
if ($default_duration) {
$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;
}