You are here

class ParagraphBlocksInlineParagraphsWidget in Paragraph blocks 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/ParagraphBlocksInlineParagraphsWidget.php \Drupal\paragraph_blocks\Plugin\Field\FieldWidget\ParagraphBlocksInlineParagraphsWidget
  2. 8 src/Plugin/Field/FieldWidget/ParagraphBlocksInlineParagraphsWidget.php \Drupal\paragraph_blocks\Plugin\Field\FieldWidget\ParagraphBlocksInlineParagraphsWidget

Extend the inline paragraphs widget.

Used to change the summary display to the admin title; and to hide the admin title on embedded paragraphs (paragraphs within paragraphs). Only top level paragraphs use the admin title.

Hierarchy

Expanded class hierarchy of ParagraphBlocksInlineParagraphsWidget

1 file declares its use of ParagraphBlocksInlineParagraphsWidget
paragraph_blocks.module in ./paragraph_blocks.module
Contains paragraph_blocks.module.

File

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

Namespace

Drupal\paragraph_blocks\Plugin\Field\FieldWidget
View source
class ParagraphBlocksInlineParagraphsWidget extends InlineParagraphsWidget {

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members