function NumericItemBase::fieldSettingsForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php \Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase::fieldSettingsForm()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php \Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase::fieldSettingsForm()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php \Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase::fieldSettingsForm()

Overrides FieldItemBase::fieldSettingsForm

2 calls to NumericItemBase::fieldSettingsForm()
DecimalItem::fieldSettingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
Returns a form for the field-level settings.
FloatItem::fieldSettingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php
Returns a form for the field-level settings.
2 methods override NumericItemBase::fieldSettingsForm()
DecimalItem::fieldSettingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
Returns a form for the field-level settings.
FloatItem::fieldSettingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php
Returns a form for the field-level settings.

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php, line 28

Class

NumericItemBase
Base class for numeric configurable field types.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
    $element = [];
    $settings = $this->getSettings();
    $element['min'] = [
        '#type' => 'number',
        '#title' => $this->t('Minimum'),
        '#default_value' => $settings['min'],
        '#element_validate' => [
            [
                static::class,
                'validateMinAndMaxConfig',
            ],
        ],
        '#description' => $this->t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
    ];
    $element['max'] = [
        '#type' => 'number',
        '#title' => $this->t('Maximum'),
        '#default_value' => $settings['max'],
        '#description' => $this->t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
    ];
    $element['prefix'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Prefix'),
        '#default_value' => $settings['prefix'],
        '#size' => 60,
        '#description' => $this->t("Define a string that should be prefixed to the value, like '\$ ' or '€ '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
    ];
    $element['suffix'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Suffix'),
        '#default_value' => $settings['suffix'],
        '#size' => 60,
        '#description' => $this->t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
    ];
    return $element;
}

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