On this page
protected function EntityForm::actionsElement
protected EntityForm::actionsElement(array $form, FormStateInterface $form_state)
Returns the action form element for the current entity form.
File
- core/lib/Drupal/Core/Entity/EntityForm.php, line 188
Class
- EntityForm
- Base class for entity forms.
Namespace
Drupal\Core\EntityCode
protected function actionsElement(array $form, FormStateInterface $form_state) {
$element = $this->actions($form, $form_state);
if (isset($element['delete'])) {
// Move the delete action as last one, unless weights are explicitly
// provided.
$delete = $element['delete'];
unset($element['delete']);
$element['delete'] = $delete;
$element['delete']['#button_type'] = 'danger';
}
if (isset($element['submit'])) {
// Give the primary submit button a #button_type of primary.
$element['submit']['#button_type'] = 'primary';
}
$count = 0;
foreach (Element::children($element) as $action) {
$element[$action] += array(
'#weight' => ++$count * 5,
);
}
if (!empty($element)) {
$element['#type'] = 'actions';
}
return $element;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityForm.php/function/EntityForm::actionsElement/8.1.x