You are here

public function SmartDateWidgetBase::settingsForm in Smart Date 3.2.x

Same name and namespace in other branches
  1. 3.0.x src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase::settingsForm()
  2. 3.1.x src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase::settingsForm()
  3. 3.3.x src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase::settingsForm()
  4. 3.4.x src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase::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

2 calls to SmartDateWidgetBase::settingsForm()
SmartDateDatelistWidget::settingsForm in src/Plugin/Field/FieldWidget/SmartDateDatelistWidget.php
Returns a form to configure settings for the widget.
SmartDateDefaultWidget::settingsForm in src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php
Returns a form to configure settings for the widget.
2 methods override SmartDateWidgetBase::settingsForm()
SmartDateDatelistWidget::settingsForm in src/Plugin/Field/FieldWidget/SmartDateDatelistWidget.php
Returns a form to configure settings for the widget.
SmartDateDefaultWidget::settingsForm in src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php
Returns a form to configure settings for the widget.

File

src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php, line 38

Class

SmartDateWidgetBase
Base class for the 'smartdate_*' widgets.

Namespace

Drupal\smart_date\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $cardinality = $this->fieldDefinition
    ->getFieldStorageDefinition()
    ->getCardinality();
  if ($cardinality != 1) {
    $element['show_extra'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Always show an extra, empty widget (Drupal default). Otherwise the user must explicitly add a new widget if needed.'),
      '#default_value' => $this
        ->getSetting('show_extra'),
    ];
  }
  $element['hide_date'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide the end date field unless it\'s different from the start date.'),
    '#default_value' => $this
      ->getSetting('hide_date'),
  ];
  return $element;
}