protected function MediaTypeForm::actions in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/src/MediaTypeForm.php \Drupal\media\MediaTypeForm::actions()
- 9 core/modules/media/src/MediaTypeForm.php \Drupal\media\MediaTypeForm::actions()
Returns an array of supported actions for the current entity form.
This function generates a list of Form API elements which represent actions supported by the current entity form.
@todo Consider introducing a 'preview' action here, since it is used by many entity types.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An array of supported Form API action elements keyed by name.
Overrides EntityForm::actions
File
- core/
modules/ media/ src/ MediaTypeForm.php, line 317
Class
- MediaTypeForm
- Form controller for media type forms.
Namespace
Drupal\mediaCode
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
// If the media source has not been chosen yet, turn the submit button into
// a button. This rebuilds the form with the media source's configuration
// form visible, instead of saving the media type. This allows users to
// create a media type without JavaScript enabled. With JavaScript enabled,
// this rebuild occurs during an AJAX request.
// @see \Drupal\media\MediaTypeForm::ajaxHandlerData()
if (empty($this
->getEntity()
->get('source'))) {
$actions['submit']['#type'] = 'button';
}
$actions['submit']['#value'] = $this
->t('Save');
$actions['delete']['#value'] = $this
->t('Delete');
$actions['delete']['#access'] = $this->entity
->access('delete');
return $actions;
}