Builds list of actions based on paragraphs type.
array The form element array.
protected function buildSelectAddMode() {
$field_name = $this->fieldDefinition
->getName();
$title = $this->fieldDefinition
->getLabel();
$add_more_elements['add_more_select'] = [
'#type' => 'select',
'#options' => $this
->getAccessibleOptions(),
'#title' => $this
->t('@title type', [
'@title' => $this
->getSetting('title'),
]),
'#label_display' => 'hidden',
];
$text = $this
->t('Add @title', [
'@title' => $this
->getSetting('title'),
]);
if ($this->realItemCount > 0) {
$text = $this
->t('Add another @title', [
'@title' => $this
->getSetting('title'),
]);
}
$add_more_elements['add_more_button'] = [
'#type' => 'submit',
'#name' => strtr($this->fieldIdPrefix, '-', '_') . '_add_more',
'#value' => $text,
'#attributes' => [
'class' => [
'field-add-more-submit',
],
],
'#limit_validation_errors' => [
array_merge($this->fieldParents, [
$field_name,
'add_more',
]),
],
'#submit' => [
[
get_class($this),
'addMoreSubmit',
],
],
'#ajax' => [
'callback' => [
get_class($this),
'addMoreAjax',
],
'wrapper' => $this->fieldWrapperId,
'effect' => 'fade',
],
];
$add_more_elements['add_more_button']['#suffix'] = $this
->t(' to %type', [
'%type' => $title,
]);
return $add_more_elements;
}