You are here

public function LogForm::submitForm in Log entity 8

Updates the log object by processing the submitted values.

This function can be called by a "Next" button of a wizard to update the form state's entity with the current step's values before proceeding to the next step.

Overrides ContentEntityForm::submitForm

File

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

Class

LogForm
Form controller for Log edit forms.

Namespace

Drupal\log\Form

Code

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

  // Build the log object from the submitted values.
  parent::submitForm($form, $form_state);
  $entity = $this->entity;

  // Save as a new revision if requested to do so.
  if (!$form_state
    ->isValueEmpty('revision') && $form_state
    ->getValue('revision') != FALSE) {
    $entity
      ->setNewRevision();

    // If a new revision is created, save the current user as revision author.
    $entity
      ->setRevisionCreationTime(REQUEST_TIME);
    $entity
      ->setRevisionAuthorId(\Drupal::currentUser()
      ->id());
  }
  else {
    $entity
      ->setNewRevision(FALSE);
  }
}