public function ParagraphsWidget::form

File

paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 1465

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) {
  $parents = $form['#parents'];

  // Identify the manage field settings default value form.
  if (in_array('default_value_input', $parents, TRUE)) {

    // Since the entity is not reusable neither cloneable, having a default
    // value is not supported.
    return [
      '#markup' => $this
        ->t('No widget available for: %label.', [
        '%label' => $items
          ->getFieldDefinition()
          ->getLabel(),
      ]),
    ];
  }
  $elements = parent::form($items, $form, $form_state, $get_delta);

  // Signal to content_translation that this field should be treated as
  // multilingual and not be hidden, see
  // \Drupal\content_translation\ContentTranslationHandler::entityFormSharedElements().
  $elements['#multilingual'] = TRUE;
  return $elements;
}