You are here

public function StarRatingItem::fieldSettingsForm in Star Rating 8.2

Same name and namespace in other branches
  1. 8.4 src/Plugin/Field/FieldType/StarRatingItem.php \Drupal\starrating\Plugin\Field\FieldType\StarRatingItem::fieldSettingsForm()
  2. 8 src/Plugin/Field/FieldType/StarRatingItem.php \Drupal\starrating\Plugin\Field\FieldType\StarRatingItem::fieldSettingsForm()
  3. 8.3 src/Plugin/Field/FieldType/StarRatingItem.php \Drupal\starrating\Plugin\Field\FieldType\StarRatingItem::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

File

src/Plugin/Field/FieldType/StarRatingItem.php, line 74

Class

StarRatingItem
Plugin implementation of the 'addtocart' field type.

Namespace

Drupal\starrating\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = [];

  // The key of the element should be the setting name.
  $element['max_value'] = [
    '#title' => $this
      ->t('Maximum rating value'),
    '#type' => 'select',
    '#options' => [
      1 => '1',
      2 => '2',
      3 => '3',
      4 => '4',
      5 => '5',
      6 => '6',
      7 => '7',
      8 => '8',
      9 => '9',
      10 => '10',
    ],
    '#default_value' => $this
      ->getSetting('max_value'),
  ];
  return $element;
}