You are here

protected function FieldWrapperBase::getSettingFromFormState in (Entity Reference) Field Formatters 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/FieldWrapperBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldWrapperBase::getSettingFromFormState()
  2. 8 src/Plugin/Field/FieldFormatter/FieldWrapperBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldWrapperBase::getSettingFromFormState()

Helper function to retrieve the $setting from the $form_state.

Parameters

Drupal\Core\Form\FormStateInterface $form_state: The form state object.

string $setting: The setting key to retrieve.

1 call to FieldWrapperBase::getSettingFromFormState()
FieldWrapperBase::settingsForm in src/Plugin/Field/FieldFormatter/FieldWrapperBase.php
Returns a form to configure settings for the formatter.

File

src/Plugin/Field/FieldFormatter/FieldWrapperBase.php, line 293

Class

FieldWrapperBase
Wraps an existing field.

Namespace

Drupal\field_formatter\Plugin\Field\FieldFormatter

Code

protected function getSettingFromFormState(FormStateInterface $form_state, $setting) {
  $field_name = $this->fieldDefinition
    ->getName();
  if ($form_state
    ->hasValue([
    'fields',
    $field_name,
    'settings_edit_form',
    'settings',
    $setting,
  ])) {
    return $form_state
      ->getValue([
      'fields',
      $field_name,
      'settings_edit_form',
      'settings',
      $setting,
    ]);
  }
  return $this
    ->getSetting($setting);
}