You are here

public function PriceDefaultFormatter::settingsForm in Commerce Core 8.2

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

1 call to PriceDefaultFormatter::settingsForm()
PriceCalculatedFormatter::settingsForm in modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php
Returns a form to configure settings for the formatter.
1 method overrides PriceDefaultFormatter::settingsForm()
PriceCalculatedFormatter::settingsForm in modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php
Returns a form to configure settings for the formatter.

File

modules/price/src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php, line 89

Class

PriceDefaultFormatter
Plugin implementation of the 'commerce_price_default' formatter.

Namespace

Drupal\commerce_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['currency_display'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Currency display'),
    '#options' => [
      'symbol' => $this
        ->t('Symbol (e.g. "$")'),
      'code' => $this
        ->t('Currency code (e.g. "USD")'),
      'none' => $this
        ->t('None'),
    ],
    '#default_value' => $this
      ->getSetting('currency_display'),
  ];
  return $elements;
}