You are here

public function LogForm::form in Log entity 8

Same name and namespace in other branches
  1. 2.x src/Form/LogForm.php \Drupal\log\Form\LogForm::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

src/Form/LogForm.php, line 23
Contains \Drupal\log\Entity\Form\LogForm.

Class

LogForm
Form controller for Log edit forms.

Namespace

Drupal\log\Form

Code

public function form(array $form, FormStateInterface $form_state) {

  /* @var $entity \Drupal\log\Entity\Log */
  $entity = $this->entity;
  $form['advanced'] = array(
    '#type' => 'vertical_tabs',
    '#attributes' => array(
      'class' => array(
        'entity-meta',
      ),
    ),
    '#weight' => 99,
  );
  $form['revision_information'] = array(
    '#type' => 'details',
    '#group' => 'advanced',
    '#title' => t('Revision information'),
    '#weight' => 20,
    '#optional' => TRUE,
  );
  $form['revision'] = array(
    '#title' => $this
      ->t('Revision'),
    '#type' => 'checkbox',
    '#default_value' => $entity->type->entity
      ->isNewRevision(),
    '#weight' => 99,
    '#group' => 'revision_information',
  );
  $form['author'] = array(
    '#type' => 'details',
    '#title' => t('Authoring information'),
    '#group' => 'advanced',
    '#weight' => 90,
    '#optional' => TRUE,
  );
  $form['langcode'] = array(
    '#title' => $this
      ->t('Language'),
    '#type' => 'language_select',
    '#default_value' => $entity->langcode->value,
    '#languages' => Language::STATE_ALL,
    '#group' => 'author',
  );
  $form = parent::form($form, $form_state);
  if (isset($form['user_id'])) {
    $form['user_id']['#group'] = 'author';
  }
  if (isset($form['created'])) {
    $form['created']['#group'] = 'author';
  }
  if (isset($form['name'])) {
    $form['name']['#access'] = $entity->type->entity
      ->isNameEditable();
  }
  return $form;
}