You are here

public function PriceDefaultFormatter::settingsForm in Price 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsForm()
  2. 3.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsForm()
  3. 2.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::settingsForm()
  4. 3.0.x src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php \Drupal\price\Plugin\Field\FieldFormatter\PriceDefaultFormatter::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/PriceDefaultFormatter.php, line 89

Class

PriceDefaultFormatter
Plugin implementation of the 'price_default' 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['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;
}