How to reset values of elements in multi-step form I'm building quite a complicated and large custom form. Below I've made a simple example form to demonstrate my case:

function mymodule_form($form, &amp;$form_state) {
  $form['step1']['element1'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Element 1',
    '#options' =&gt; array('All' =&gt; '- Any -', 'option1' =&gt; 'Option 1', 'option2' =&gt; 'Option 2'),
  );

  $form['step1']['element2'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Element 2',
    '#options' =&gt; array('All' =&gt; '- Any -', 'option1' =&gt; 'Option 1', 'option2' =&gt; 'Option 2'),
  );

  $form['step1']['addfilter'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Add filter',
    '#name' =&gt; 'addfilter',
    '#ajax' =&gt; array(
      'callback' =&gt; 'mymodule_form_callback',
      'wrapper' =&gt; 'results-div',
    ),
  );

  $form['step2'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Results'),
    '#prefix' =&gt; '&lt;div id="results-div"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  );

  // Ajax values process
  if(isset($form_state['values'])) {
    foreach($form_state['values'] as $key =&gt; $value) {
      if($value != 'All') {
        $form['step2']['step2-'.$key] = array(
          '#type' =&gt; 'button',
          '#value' =&gt; 'remove ' . $key,
          '#name' =&gt; 'step2-'.$key,
          '#ajax' =&gt; array(
            'callback' =&gt; 'mymodule_form_remove_callback',
            'wrapper' =&gt; 'results-div',
          ),
        );
      }
    }
  }
}

function mymodule_form_callback($form, &amp;$form_state) {
  return $form['step2'];
}

function mymodule_form_remove_callback($form, &amp;$form_state) {
  // What to do here???
}


Basically what should happen is:


Select a value from the step1 elements
Click Add Filter button
The form function runs again, and this time it creates ajax'd "remove" buttons under step2.
When you press the remove button, the corresponding form element in step1 should get its value reset to 'All' and the corresponding step2 button needs to get removed.


I'm getting stuck at step 4, I'm not sure how to reset a submitted multi-step form's values.
As I understand it, you don't need the ajax callback for the remove button. You should be able to do that with just using jQuery, and a rel attribute to hold the ID. Consider the following:

Add a class for the jQuery script and a rel attribute that holds the Step 1 element count id to the remove button.

$form['step2']['step2-'.$key] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; 'remove ' . $key,
  '#name' =&gt; 'step2-'.$key,
  '#attributes' =&gt; array('rel' =&gt; 1, 'class' =&gt; 'remove-button'),
);



jQuery script to remove the "remove" button and reset the the Step 1 form element.

$('.remove-button').click(function(e) {
  var id = $(this).attr('rel');
  $('#element'+ id +').val('All');
  $(this).closest('.button-wrapper-class').remove();
  e.preventDefault();
});



This is (most likely) non-working example code, but I think you'll understand my point.