function hook_node_submit

Act on a node after validated form values have been copied to it.

This hook is invoked when a node form is submitted with either the "Save" or "Preview" button, after form values have been copied to the form state's node object, but before the node is saved or previewed. It is a chance for modules to adjust the node's properties from what they are simply after a copy from $form_state['values']. This hook is intended for adjusting non-field-related properties. See hook_field_attach_extract_form_values() for customizing field-related properties.

Parameters

\Drupal\Core\Entity\EntityInterface $node: The node entity being updated in response to a form submission.

$form: The form being used to edit the node.

$form_state: The form state array.

Related topics

1 function implements hook_node_submit()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

menu_node_submit in drupal/core/modules/menu/menu.module
Implements hook_node_submit().
1 invocation of hook_node_submit()
NodeFormController::submit in drupal/core/modules/node/lib/Drupal/node/NodeFormController.php
Updates the node object by processing the submitted values.

File

drupal/core/modules/node/node.api.php, line 785
Hooks provided by the Node module.

Code

function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) {

  // Decompose the selected menu parent option into 'menu_name' and 'plid', if
  // the form used the default parent selection widget.
  if (!empty($form_state['values']['menu']['parent'])) {
    list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);
  }
}