| 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 |
|
|
| 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" |
| 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. |
| 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 |
|
|
| 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; |
| 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; |
| 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 |
|
|
| 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 |
|
|