protected function ParagraphsWidget::buildAddActions in Paragraphs 8
Add 'add more' button, if not working with a programmed form.
Return value
array The form element array.
1 call to ParagraphsWidget::buildAddActions()
- ParagraphsWidget::formMultipleElements in src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php - Special handling to create form elements for multiple values.
File
- src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php, line 1417
Class
- ParagraphsWidget
- Plugin implementation of the 'entity_reference_revisions paragraphs' widget.
Namespace
Drupal\paragraphs\Plugin\Field\FieldWidgetCode
protected function buildAddActions() {
if (count($this
->getAccessibleOptions()) === 0) {
if (count($this
->getAllowedTypes()) === 0) {
$add_more_elements['icons'] = $this
->createMessage($this
->t('You are not allowed to add any of the @title types.', [
'@title' => $this
->getSetting('title'),
]));
}
else {
$add_more_elements['icons'] = $this
->createMessage($this
->t('You did not add any @title types yet.', [
'@title' => $this
->getSetting('title'),
]));
}
return $add_more_elements;
}
if (in_array($this
->getSetting('add_mode'), [
'button',
'dropdown',
'modal',
])) {
return $this
->buildButtonsAddMode();
}
return $this
->buildSelectAddMode();
}