Index: modules/field/field.form.inc ========================================================= --- modules/field/field.form.inc (revision 1.14) +++ modules/field/field.form.inc Mon Aug 17 12:24:12 PDT 2009 @@ -191,7 +191,10 @@ // Submit callback for disabled JavaScript. '#submit' => array('field_add_more_submit'), '#ajax' => array( - 'path' => 'field/js_add_more/' . $bundle_name_url_css . '/' . $field_name_url_css, + // @todo : Once 'callback' is accepted as the prefered implementation, + // remove the 'path' attribute. + //'path' => 'field/js_add_more/' . $bundle_name_url_css . '/' . $field_name_url_css, + 'callback' => 'field_add_more_js', 'wrapper' => $field_name_url_css . '-wrapper', 'method' => 'replace', 'effect' => 'fade', @@ -333,6 +336,37 @@ /** * Menu callback for AHAH addition of new empty widgets. */ +// @todo : Waiting on http://drupal.org/node/370537 to figure out validation +function field_add_more_js($form, $form_state) { + $field_name = $form_state['clicked_button']['#field_name']; + $bundle_name = $form_state['clicked_button']['#bundle']; + + // Retrieve field information. + $field = $form['#fields'][$field_name]['field']; + $instance = $form['#fields'][$field_name]['instance']; + $form_path = $form['#fields'][$field_name]['form_path']; + + // Fetch the form element that needs rendering. + $field_form = $form; + foreach ($form_path as $key) { + $field_form = $field_form[$key]; + } + + // Add a DIV around the new field to receive the AJAX effect. + $delta = max(element_children($field_form)); + $field_form[$delta]['#prefix'] = '