function FieldBlock::formatterSettingsProcessCallback

Same name and namespace in other branches
  1. 8.9.x core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::formatterSettingsProcessCallback()
  2. 10 core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::formatterSettingsProcessCallback()
  3. 11.x core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::formatterSettingsProcessCallback()

Render API callback: builds the formatter settings elements.

File

core/modules/layout_builder/src/Plugin/Block/FieldBlock.php, line 286

Class

FieldBlock
Provides a block that renders a field from an entity.

Namespace

Drupal\layout_builder\Plugin\Block

Code

public function formatterSettingsProcessCallback(array &$element, FormStateInterface $form_state, array &$complete_form) {
    if ($formatter = $this->getFormatter($element['#parents'], $form_state)) {
        $element['settings_wrapper']['settings'] = $formatter->settingsForm($complete_form, $form_state);
        $element['settings_wrapper']['settings']['#parents'] = array_merge($element['#parents'], [
            'settings',
        ]);
        $element['settings_wrapper']['third_party_settings'] = $this->thirdPartySettingsForm($formatter, $this->getFieldDefinition(), $complete_form, $form_state);
        $element['settings_wrapper']['third_party_settings']['#parents'] = array_merge($element['#parents'], [
            'third_party_settings',
        ]);
        FormHelper::rewriteStatesSelector($element['settings_wrapper'], "fields[{$this->fieldName}][settings_edit_form]", 'settings[formatter]');
        // Store the array parents for our element so that we can retrieve the
        // formatter settings in our AJAX callback.
        $form_state->set('field_block_array_parents', $element['#array_parents']);
    }
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.