You are here

public function MediaForm::form in Media entity 8

File

src/MediaForm.php, line 44

Class

MediaForm
Form controller for the media edit forms.

Namespace

Drupal\media_entity

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // 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' => [
          'node-form-author',
        ],
      ],
      '#attached' => [
        'library' => [
          'node/drupal.node',
        ],
      ],
      '#weight' => 90,
      '#optional' => TRUE,
    ];
  }
  if (isset($form['uid'])) {
    $form['uid']['#group'] = 'author';
  }
  if (isset($form['created'])) {
    $form['created']['#group'] = 'author';
  }
  $form['#attached']['library'][] = 'node/form';
  $form['#entity_builders']['update_status'] = [
    $this,
    'updateStatus',
  ];
  return $form;
}