function StringTextfieldWidget::settingsForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget::settingsForm()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget::settingsForm()
  3. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget::settingsForm()

Overrides WidgetBase::settingsForm

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php, line 34

Class

StringTextfieldWidget
Plugin implementation of the 'string_textfield' widget.

Namespace

Drupal\Core\Field\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
    $element['size'] = [
        '#type' => 'number',
        '#title' => $this->t('Size of textfield'),
        '#default_value' => $this->getSetting('size'),
        '#required' => TRUE,
        '#min' => 1,
    ];
    $element['placeholder'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Placeholder'),
        '#default_value' => $this->getSetting('placeholder'),
        '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
    ];
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.