How can a form remember the selected tab after submit? I'm using vertical tabs in a form, and I keep all the values with $form_state-&gt;setRebuild(true);. In this way, the user can change some of the submitted values.

I would like to keep the selected tab active as well. How can I achieve this?

If there aren't other solutions, I will use JavaScript to manually select the tab after the form is reloaded.
You should be able to see which vertical tab was selected at the time your form was submitted. If not, you can certainly use js and a hidden field to keep track of it. Once you have it submitted your form then you can easily set the #default_tab of your vertical tabs based on the value in your the recently selected tab. Something like this:

$form['information'] = array(
  '#type' =&gt; 'vertical_tabs',
  '#default_tab' =&gt; isset($form_state['values']['selected_tab'][...) ? $form_state['values']['selected_tab'][... : "some_tab",
);


Another option would be to use a pure js solution. By storing the currently selected tab in local storage and then selecting that tab when the form loads should work as well. In this case you may see your form "flash" as the selected tab is selected but that may or may not be a problem depending on your form and desired UX