public function MediaForm::form in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/src/MediaForm.php \Drupal\media\MediaForm::form()
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- core/
modules/ media/ src/ MediaForm.php, line 18
Class
- MediaForm
- Form controller for the media edit forms.
Namespace
Drupal\mediaCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\media\MediaTypeInterface $media_type */
$media_type = $this->entity->bundle->entity;
if ($this->operation === 'edit') {
$form['#title'] = $this
->t('Edit %type_label @label', [
'%type_label' => $media_type
->label(),
'@label' => $this->entity
->label(),
]);
}
// Media author information for administrators.
if (isset($form['uid']) || isset($form['created'])) {
$form['author'] = [
'#type' => 'details',
'#title' => $this
->t('Authoring information'),
'#group' => 'advanced',
'#attributes' => [
'class' => [
'media-form-author',
],
],
'#weight' => 90,
'#optional' => TRUE,
];
}
if (isset($form['uid'])) {
$form['uid']['#group'] = 'author';
}
if (isset($form['created'])) {
$form['created']['#group'] = 'author';
}
$form['#attached']['library'][] = 'media/form';
return $form;
}