Skip to main content
User wanted to see Drupal 8 version.
Source Link
featherbelly
  • 1.1k
  • 10
  • 17

Drupal 7

If you are not redirecting and want to preserve the values in the Form API fields add $form_state['rebuild'] = TRUE; on the submit handler.

/**
 * FORM submit handler.
 */
function FORM_form_submit($node, &$form_state) {
  // Rebuild the form and keep the filter values.
  $form_state['rebuild'] = TRUE;
}

Drupal 8

In Drupal 8 you would use $form_state-> setRebuild();

See public function FormState::setRebuild for more detail.

Custom submit handlers in Drupal 8 are dealt with differently — here is some useful discussion on Drupal 8 submit handlers.

If you are not redirecting and want to preserve the values in the Form API fields add $form_state['rebuild'] = TRUE; on the submit handler.

/**
 * FORM submit handler.
 */
function FORM_form_submit($node, &$form_state) {
  // Rebuild the form and keep the filter values.
  $form_state['rebuild'] = TRUE;
}

Drupal 7

If you are not redirecting and want to preserve the values in the Form API fields add $form_state['rebuild'] = TRUE; on the submit handler.

/**
 * FORM submit handler.
 */
function FORM_form_submit($node, &$form_state) {
  // Rebuild the form and keep the filter values.
  $form_state['rebuild'] = TRUE;
}

Drupal 8

In Drupal 8 you would use $form_state-> setRebuild();

See public function FormState::setRebuild for more detail.

Custom submit handlers in Drupal 8 are dealt with differently — here is some useful discussion on Drupal 8 submit handlers.

Source Link
featherbelly
  • 1.1k
  • 10
  • 17

If you are not redirecting and want to preserve the values in the Form API fields add $form_state['rebuild'] = TRUE; on the submit handler.

/**
 * FORM submit handler.
 */
function FORM_form_submit($node, &$form_state) {
  // Rebuild the form and keep the filter values.
  $form_state['rebuild'] = TRUE;
}