You are here

public function PriceModifiedDefaultFormatter::settingsForm in Price 8

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldFormatter/PriceModifiedDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceModifiedDefaultFormatter::settingsForm()
  2. 3.0.x src/Plugin/Field/FieldFormatter/PriceModifiedDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceModifiedDefaultFormatter::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/PriceModifiedDefaultFormatter.php, line 118

Class

PriceModifiedDefaultFormatter
Plugin implementation of the 'price_modified' formatter.

Namespace

Drupal\price\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = [];
  $elements['strip_trailing_zeroes'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Strip trailing zeroes after the decimal point.'),
    '#default_value' => $this
      ->getSetting('strip_trailing_zeroes'),
  ];
  $elements['display_currency_code'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display the currency code instead of the currency symbol.'),
    '#default_value' => $this
      ->getSetting('display_currency_code'),
  ];
  $elements['display_modifier'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display the modifier.'),
    '#default_value' => $this
      ->getSetting('display_modifier'),
  ];
  return $elements;
}