You are here

public function LayoutParagraphsWidget::settingsForm in Layout Paragraphs 1.0.x

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php \Drupal\layout_paragraphs\Plugin\Field\FieldWidget\LayoutParagraphsWidget::settingsForm()

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php, line 2234

Class

LayoutParagraphsWidget
Entity Reference with Layout field widget.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $entity_type_id = $this
    ->getFieldSetting('target_type');
  $element = parent::settingsForm($form, $form_state);
  $element['preview_view_mode'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Preview view mode'),
    '#default_value' => $this
      ->getSetting('preview_view_mode'),
    '#options' => $this->entityDisplayRepository
      ->getViewModeOptions($entity_type_id),
    '#description' => $this
      ->t('View mode for the referenced entity preview on the edit form. Automatically falls back to "default", if it is not enabled in the referenced entity type displays.'),
  ];
  $element['nesting_depth'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Maximum nesting depth'),
    '#options' => range(0, 10),
    '#default_value' => $this
      ->getSetting('nesting_depth'),
    '#description' => $this
      ->t('Choosing 0 will prevent nesting layouts within other layouts.'),
  ];
  $element['require_layouts'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Require paragraphs to be added inside a layout'),
    '#default_value' => $this
      ->getSetting('require_layouts'),
  ];
  return $element;
}