You are here

public function UnlimitedNumberWidget::settingsForm in Unlimited Number Field 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/UnlimitedNumberWidget.php \Drupal\unlimited_number\Plugin\Field\FieldWidget\UnlimitedNumberWidget::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 NumberWidget::settingsForm

File

src/Plugin/Field/FieldWidget/UnlimitedNumberWidget.php, line 37

Class

UnlimitedNumberWidget
Plugin implementation of the 'unlimited_number' widget.

Namespace

Drupal\unlimited_number\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $element['value_unlimited'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Unlimited value'),
    '#default_value' => $this
      ->getSetting('value_unlimited'),
    '#description' => $this
      ->t('Internal number to use for unlimited.'),
  ];
  $element['label_unlimited'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Unlimited Label'),
    '#default_value' => $this
      ->getSetting('label_unlimited'),
    '#description' => $this
      ->t('Text that will be used for the unlimited radio.'),
  ];
  $element['label_number'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Number Label'),
    '#default_value' => $this
      ->getSetting('label_number'),
    '#description' => $this
      ->t('Text that will be used for the number radio.'),
  ];
  return $element;
}