NodeForm::submitForm

public NodeForm::submitForm(array &$form, FormStateInterface $form_state)

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 315

Class

NodeForm
Form handler 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->setRevisionUserId(\Drupal::currentUser()->id());
  }
  else {
    $node->setNewRevision(FALSE);
  }
}
doc_Drupal
2016-10-29 09:30:46
Comments
Leave a Comment

Please login to continue.