Add 'add more' button, if not working with a programmed form.
array The form element array.
protected function buildAddActions() {
if (count($this
->getAccessibleOptions()) === 0) {
if (count($this
->getAllowedTypes()) === 0) {
$add_more_elements['info'] = [
'#type' => 'container',
'#markup' => $this
->t('You are not allowed to add any of the @title types.', [
'@title' => $this
->getSetting('title'),
]),
'#attributes' => [
'class' => [
'messages',
'messages--warning',
],
],
];
}
else {
$add_more_elements['info'] = [
'#type' => 'container',
'#markup' => $this
->t('You did not add any @title types yet.', [
'@title' => $this
->getSetting('title'),
]),
'#attributes' => [
'class' => [
'messages',
'messages--warning',
],
],
];
}
return $add_more_elements;
}
if ($this
->getSetting('add_mode') == 'button' || $this
->getSetting('add_mode') == 'dropdown') {
return $this
->buildButtonsAddMode();
}
return $this
->buildSelectAddMode();
}