You are here

public function ProductVariationTitleWidget::settingsForm in Commerce Core 8.2

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

File

modules/product/src/Plugin/Field/FieldWidget/ProductVariationTitleWidget.php, line 38

Class

ProductVariationTitleWidget
Plugin implementation of the 'commerce_product_variation_title' widget.

Namespace

Drupal\commerce_product\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $element['label_display'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display label'),
    '#default_value' => $this
      ->getSetting('label_display'),
  ];
  $element['label_text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label text'),
    '#default_value' => $this
      ->getSetting('label_text'),
    '#description' => $this
      ->t('The label will be available to screen readers even if it is not displayed.'),
    '#required' => TRUE,
  ];
  $element['hide_single'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t("Hide if there's only one product variation"),
    '#default_value' => $this
      ->getSetting('hide_single'),
  ];
  return $element;
}