public function NumericItemBase::fieldSettingsForm in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php \Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase::fieldSettingsForm()
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php \Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase::fieldSettingsForm()
Returns a form for the field-level settings.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
Return value
array The form definition for the field settings.
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\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = [];
$settings = $this
->getSettings();
$element['min'] = [
'#type' => 'number',
'#title' => t('Minimum'),
'#default_value' => $settings['min'],
'#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
];
$element['max'] = [
'#type' => 'number',
'#title' => t('Maximum'),
'#default_value' => $settings['max'],
'#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
];
$element['prefix'] = [
'#type' => 'textfield',
'#title' => t('Prefix'),
'#default_value' => $settings['prefix'],
'#size' => 60,
'#description' => 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' => t('Suffix'),
'#default_value' => $settings['suffix'],
'#size' => 60,
'#description' => 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;
}