/[drupal]/contributions/modules/ahah_helper/ahah_helper.module
ViewVC logotype

Diff of /contributions/modules/ahah_helper/ahah_helper.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Fri Aug 29 18:58:21 2008 UTC revision 1.2, Wed Nov 19 16:25:29 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: ahah_helper.module,v 1.1 2008/08/29 18:58:21 wimleers Exp $
3    
4  define('AHAH_HELPER_CALLBACK', 'ahah_helper/');  define('AHAH_HELPER_CALLBACK', 'ahah_helper/');
5    
# Line 119  function ahah_helper_render($form_item_t Line 119  function ahah_helper_render($form_item_t
119    // Rebuild the form.    // Rebuild the form.
120    $args = $form['#parameters'];    $args = $form['#parameters'];
121    array_shift($args); // We don't have to pass the form id again.    array_shift($args); // We don't have to pass the form id again.
122    $form = drupal_update_form($form_id, &$form_state, $args, $form_build_id, $form_item_to_render, $existing_form_items);    $form = drupal_update_form($form_id, $form_state, $args, $form_build_id, $form_item_to_render, $existing_form_items);
123    $form['#programmed'] = FALSE;    $form['#programmed'] = FALSE;
124    
125    // We *do* save the form to the cache, so modules that use "D6 core style"    // We *do* save the form to the cache, so modules that use "D6 core style"
# Line 176  function drupal_update_form($form_id, &$ Line 176  function drupal_update_form($form_id, &$
176    
177    // Build the form, so we can render it, or continue processing it (call    // Build the form, so we can render it, or continue processing it (call
178    // validate and/or submit handlers)    // validate and/or submit handlers)
179    $form = form_builder($form_id, $form, &$form_state);    $form = form_builder($form_id, $form, $form_state);
180    
181    // Disable validation for form items that are being displayed for the first    // Disable validation for form items that are being displayed for the first
182    // time.    // time.
# Line 192  function drupal_update_form($form_id, &$ Line 192  function drupal_update_form($form_id, &$
192    // trigger partial updates of the form, not for an actual submit.    // trigger partial updates of the form, not for an actual submit.
193    $errors = _ahah_helper_collect_relevant_errors(_ahah_helper_get_form_item($form, $form_item_to_render));    $errors = _ahah_helper_collect_relevant_errors(_ahah_helper_get_form_item($form, $form_item_to_render));
194    if (!$errors && count($form_state['submit_handlers'])) {    if (!$errors && count($form_state['submit_handlers'])) {
195      form_execute_handlers('submit', $form, &$form_state);      form_execute_handlers('submit', $form, $form_state);
196    
197      $form = call_user_func_array('drupal_retrieve_form', $args);      $form = call_user_func_array('drupal_retrieve_form', $args);
198    
# Line 209  function drupal_update_form($form_id, &$ Line 209  function drupal_update_form($form_id, &$
209      $form['#programmed'] = TRUE;      $form['#programmed'] = TRUE;
210    
211      // Build the form.      // Build the form.
212      $form = form_builder($form_id, $form, &$form_state);      $form = form_builder($form_id, $form, $form_state);
213    }    }
214    
215    return $form;    return $form;
# Line 252  function &_ahah_helper_get_form_item(&$f Line 252  function &_ahah_helper_get_form_item(&$f
252    if (count($parents)) {    if (count($parents)) {
253      $parent = array_shift($parents);      $parent = array_shift($parents);
254      if (isset($form[$parent])) {      if (isset($form[$parent])) {
255        return _ahah_helper_get_form_item(&$form[$parent], $parents);        return _ahah_helper_get_form_item($form[$parent], $parents);
256      }      }
257      else {      else {
258        return NULL;        return NULL;
# Line 278  function &_ahah_helper_get_form_item(&$f Line 278  function &_ahah_helper_get_form_item(&$f
278  function _ahah_helper_detect_form_items($form, &$existing_form_items) {  function _ahah_helper_detect_form_items($form, &$existing_form_items) {
279    foreach(element_children($form) as $child) {    foreach(element_children($form) as $child) {
280      $existing_form_items[$child]['exists'] = TRUE;      $existing_form_items[$child]['exists'] = TRUE;
281      _ahah_helper_detect_form_items($form[$child], &$existing_form_items[$child]);      _ahah_helper_detect_form_items($form[$child], $existing_form_items[$child]);
282    }    }
283  }  }
284    
# Line 298  function _ahah_helper_new_form_items_dis Line 298  function _ahah_helper_new_form_items_dis
298        $form[$child]['#validated'] = TRUE;        $form[$child]['#validated'] = TRUE;
299        $form[$child]['#first_time'] = TRUE;        $form[$child]['#first_time'] = TRUE;
300      }      }
301      _ahah_helper_new_form_items_disable_validation(&$form[$child], $existing_form_items[$child]);      _ahah_helper_new_form_items_disable_validation($form[$child], $existing_form_items[$child]);
302    }    }
303  }  }
304    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2