You are here

public function NodeForm::submitForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/NodeForm.php \Drupal\node\NodeForm::submitForm()

Updates the node 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

core/modules/node/src/NodeForm.php, line 320
Contains \Drupal\node\NodeForm.

Class

NodeForm
Form controller for the node edit forms.

Namespace

Drupal\node

Code

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

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

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

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