Builds an add paragraph button for opening of modal form.
array $element: Render element.
protected function buildModalAddForm(array &$element) {
// Attach the theme for the dialog template.
$element['#theme'] = 'paragraphs_add_dialog';
$element['add_modal_form_area'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'paragraph-type-add-modal',
'first-button',
],
],
'#access' => $this
->allowReferenceChanges(),
'#weight' => -2000,
];
$element['add_modal_form_area']['add_more'] = [
'#type' => 'submit',
'#value' => $this
->t('Add @title', [
'@title' => $this
->getSetting('title'),
]),
'#name' => 'button_add_modal',
'#attributes' => [
'class' => [
'field-add-more-submit',
'paragraph-type-add-modal-button',
'js-show',
'button--small',
],
],
];
$element['#attached']['library'][] = 'paragraphs/drupal.paragraphs.modal';
if ($this
->isFeatureEnabled('add_above')) {
$element['#attached']['library'][] = 'paragraphs/drupal.paragraphs.add_above_button';
}
}