Form rebuild without using buttons I'm trying to figure out how to rebuild a form without using a button click trigger. Instead, I'm looking to rebuild whenever a blur event occurs on a textfield. All non-button form types lack the #submit value. It doesn't seem possible to trigger a form rebuild with $form_state['rebuild'] = TRUE; unless the submit callback is triggered. Demo code below.

function test_form($form, &amp;$form_state) {
  $form['form_wrapper'] = array(
    '#prefix' =&gt; '&lt;div id="form_wrapper"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  );

  if (isset($form_state['textfield_vale'])) {
    $textfield_vale = $form_state['textfield_vale'];
  }
  else {
    $textfield_vale = 'not set';
  }

  //will not trigger page rebuild
  $form['form_wrapper']['test_textfield'] = array(
    '#type' =&gt; 'textfield',
    '#value' =&gt; 'Value = '.$textfield_vale,
    '#ajax' =&gt; array(
      'callback' =&gt; 'test_result',
      'wrapper' =&gt; 'form_wrapper',
      'event' =&gt; 'blur',
     ),
  );

  //will trigger page rebuild, changing the textfield value
  $form['form_wrapper']['trigger_rebuild'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'I don\'t want to press it',
    '#submit' =&gt; array('submit_rebuild'), //has #submit value unique to buttons
    '#ajax' =&gt; array(
      'callback' =&gt; 'test_result_with_button',
      'wrapper' =&gt; 'form_wrapper',
    ),
  );

  return $form;
}

function test_result($form, &amp;$form_state) { //unable to set $form_state['rebuild'] = TRUE
  $form_state['textfield_vale'] = 'textfield trigger'; //TRUE;
  $form_state['rebuild'] = TRUE;
  return $form['form_wrapper'];
}

function submit_rebuild($form, &amp;$form_state) {
  $form_state['textfield_vale'] = 'button trigger'; //TRUE;
  $form_state['rebuild'] = TRUE;
}

function test_result_with_button($form, $form_state) {
  return $form['form_wrapper'];
}


Is there a way to trigger a form rebuild without clicking a button (perhaps with an ajax command)? Alternatively, how can I change my code to allow an ajax callback to change $form_state values?
I've always handled changing form values in the form build or form_alter function itself. I can't remember where I saw to do this, but I've never been able to alter the form in the ajax callback itself.

Have your form trigger an ajax callback. This should return the form or piece of the form in question, like your test_result_with_button() function. 

When an ajax callback is triggered, the build method and alters are run again. Add logic in your build / form_alter to make updates to the form or form_state based on whichever action was triggered. Information about how the rebuild was triggered will be available in $form_state['triggering_element'].