You are here

public function FontAwesomeIconFormatter::settingsForm in Font Awesome Icons 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

File

src/Plugin/Field/FieldFormatter/FontAwesomeIconFormatter.php, line 62

Class

FontAwesomeIconFormatter
Implementation of Font Awesome icon formatter.

Namespace

Drupal\fontawesome\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // Load the configuration settings.
  $configuration_settings = $this->configFactory
    ->get('fontawesome.settings');

  // Setting for optional download link.
  $elements['layers'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display multi-value fields as layers?'),
    '#default_value' => $this
      ->getSetting('layers'),
    '#description' => $this
      ->t('Layers are the new way to place icons and text visually on top of each other, replacing the Font Awesome classic icons stacks. With this new approach you can use more than 2 icons. Layers are awesome when you don’t want your page’s background to show through, or when you do want to use multiple colors, layer several icons, layer text, or layer counters onto an icon. Note that layers only work with the SVG version of Font Awesome. For more information, see @layersLink.', [
      '@layersLink' => Link::fromTextAndUrl($this
        ->t('the Font Awesome guide to layers'), Url::fromUri('https://fontawesome.com/how-to-use/on-the-web/styling/layering'))
        ->toString(),
    ]),
    // Disable power transforms for webfonts.
    '#disabled' => $configuration_settings
      ->get('method') == 'webfonts',
  ];
  return $elements;
}