You are here

public function ParagraphBlocksInlineParagraphsWidget::formElement in Paragraph blocks 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/ParagraphBlocksInlineParagraphsWidget.php \Drupal\paragraph_blocks\Plugin\Field\FieldWidget\ParagraphBlocksInlineParagraphsWidget::formElement()
  2. 3.x src/Plugin/Field/FieldWidget/ParagraphBlocksInlineParagraphsWidget.php \Drupal\paragraph_blocks\Plugin\Field\FieldWidget\ParagraphBlocksInlineParagraphsWidget::formElement()

Uses a similar approach to populate a new translation.

Overrides InlineParagraphsWidget::formElement

See also

\Drupal\content_translation\Controller\ContentTranslationController::prepareTranslation()

File

src/Plugin/Field/FieldWidget/ParagraphBlocksInlineParagraphsWidget.php, line 21

Class

ParagraphBlocksInlineParagraphsWidget
Extend the inline paragraphs widget.

Namespace

Drupal\paragraph_blocks\Plugin\Field\FieldWidget

Code

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $element = parent::formElement($items, $delta, $element, $form, $form_state);

  // Hide admin_label when this is not a top level paragraph. It is not a
  // top level paragraph if there are multiple subforms.
  $subform =& $element['subform'];
  if (isset($subform['#parents']) && count(array_intersect($subform['#parents'], [
    'subform',
  ])) > 1) {
    $subform['admin_title']['#access'] = FALSE;
  }
  return $element;
}