Fix for a 'hello world' example with AHAH

  1. function _update_available_vehicles_select_list() {
  2.   // We're starting in step #3, preparing for #4.
  3.   $form_state = array('storage' => NULL, 'submitted' => FALSE);
  4.   $form_build_id = $_POST['form_build_id'];
  5.   // Step #4.
  6.   $form = form_get_cache($form_build_id, $form_state);
  7.   // Preparing for #5.
  8.   $args = $form['#parameters'];
  9.   $form_id = array_shift($args);
  10.   $form_state['post'] = $form['#post'] = $_POST;
  11.   $form['#programmed'] = $form['#redirect'] = FALSE;
  12.  
  13.   $form['field_car_available']['#title'] = 'hello world';
  14.  
  15.   // Step #5.
  16.   drupal_process_form($form_id, $form, $form_state);
  17.   // Step #6 and #7 and #8.
  18.   $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
  19.  
  20.   // Step #9.
  21.   $choice_form = $form['field_car_available']['#title'];
  22.   unset($choice_form['#prefix'], $choice_form['#suffix']);
  23.   $output = theme('status_messages') . drupal_render($choice_form);
  24.  
  25.   // Final rendering callback.
  26.   drupal_json(array('status' => TRUE, 'data' => $output));
  27. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.