You are here

protected function LayoutParagraphsBuilderFormatter::widgetInstance in Layout Paragraphs 2.0.x

Returns a layout paragraphs field widget with correct settings applied.

Return value

\Drupal\Core\Field\WidgetInterface The widget instance.

2 calls to LayoutParagraphsBuilderFormatter::widgetInstance()
LayoutParagraphsBuilderFormatter::settingsForm in src/Plugin/Field/FieldFormatter/LayoutParagraphsBuilderFormatter.php
Replicates settings from Layout Paragraphs Widget.
LayoutParagraphsBuilderFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/LayoutParagraphsBuilderFormatter.php
Replicates settings from Layout Paragraphs Widget.

File

src/Plugin/Field/FieldFormatter/LayoutParagraphsBuilderFormatter.php, line 145

Class

LayoutParagraphsBuilderFormatter
Layout Paragraphs field formatter.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldFormatter

Code

protected function widgetInstance() {
  $plugin_manager = \Drupal::service('plugin.manager.field.widget');
  $widget = $plugin_manager
    ->getInstance([
    'field_definition' => $this->fieldDefinition,
    'form_mode' => 'layout_paragraphs_editor',
    'prepare' => TRUE,
    'configuration' => [
      'type' => 'layout_paragraphs',
      'settings' => $this
        ->getSettings(),
      'third_party_settings' => [],
    ],
  ]);
  return $widget;
}