You are here

public function ComputedFieldItemBase::fieldSettingsForm in Computed Field 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/ComputedFieldItemBase.php \Drupal\computed_field\Plugin\Field\FieldType\ComputedFieldItemBase::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

1 call to ComputedFieldItemBase::fieldSettingsForm()
ComputedDecimalItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedDecimalItem.php
Returns a form for the field-level settings.
1 method overrides ComputedFieldItemBase::fieldSettingsForm()
ComputedDecimalItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedDecimalItem.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/ComputedFieldItemBase.php, line 30

Class

ComputedFieldItemBase
Plugin base of the generic field type.

Namespace

Drupal\computed_field\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = $this
    ->getFieldSettingsFormBase($form, $form_state);
  $settings = $this
    ->getSettings();
  $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;
}