/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $entity_type = $this->entity->getEntityType(); $bundle_entity = $this->getBundleEntity(); $account = $this->currentUser(); if ($this->operation == 'edit') { $form['#title'] = $this->t('Edit %bundle_label @label', ['%bundle_label' => $bundle_entity ? $bundle_entity->label() : '', '@label' => $this->entity->label()]); } $form['advanced'] = ['#type' => 'vertical_tabs', '#weight' => 99]; // Add a log field if the "Create new revision" option is checked, or if the // current user has the ability to check that option. // @todo Could we autogenerate this form by using some widget on the // revision info field. $form['revision_information'] = ['#type' => 'details', '#title' => $this->t('Revision information'), '#open' => $this->entity->isNewRevision(), '#group' => 'advanced', '#weight' => 20, '#access' => $this->entity->isNewRevision() || $account->hasPermission($entity_type->get('admin_permission'))]; $form['revision_information']['revision'] = ['#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => $this->entity->isNewRevision(), '#access' => $account->hasPermission($entity_type->get('admin_permission'))]; // Check the revision log checkbox when the log textarea is filled in. // This must not happen if "Create new revision" is enabled by default, // since the state would auto-disable the checkbox otherwise. if (!$this->entity->isNewRevision()) { $form['revision_information']['revision']['#states'] = ['checked' => ['textarea[name="revision_log"]' => ['empty' => FALSE]]]; } $form['revision_information']['revision_log'] = ['#type' => 'textarea', '#title' => $this->t('Revision log message'), '#rows' => 4, '#default_value' => $this->entity->getRevisionLogMessage(), '#description' => $this->t('Briefly describe the changes you have made.')]; return parent::form($form, $form_state); }