[System information]
CentOS 5.5 / Apache 2 / PostgreSQL / Drupal 7.4 in Chinese (drupal-7.0.zh-hans.po)
[What happened]
When implementing ajax-enabled form with "hook_form()" or "hook_form_FORM_ID_alter()", the ajax-enabled forms work just as expected, but the following warning message always appear:
"Warning: end() [function.end]: Passed variable is not an array or object 在 file_managed_file_validate() (行 536 在 /usr/local....../modules/file/file.module)."
(When the form is displayed, no such message appears, only when use the ajax function, the message will appear, if you turn off the warning message of the site, everying will be just OK!)
I've tried the example code of "Example Moudule" with "hook_form_FORM_ID_alter()" and "hook_form", the same problem. So I think the problem is not from the "ajax" part of the code, anyway I put my code here:
function my_module_form_catering_node_form_alter(&$form, &$form_state, $form_id) {
// ...........
$dist_options = _convert_terms_to_options(taxonomy_get_tree($locations_vid, 0, 1));
// ............
$form['baijia_base_dist']['und']['#default_value'] = $dist_tid;
$form['baijia_base_dist']['und']['#options'] = $dist_options;
$form['baijia_base_dist']['und']['#ajax'] = array('callback' => 'dist_ajax_callback', 'wrapper' => 'replace_element_div1',);
$form['baijia_base_locations']['und']['#multiple'] = TRUE;
$form['baijia_base_locations']['und']['#default_value'] = $locations_default_value;
$form['baijia_base_locations']['und']['#options'] = _convert_terms_to_options(taxonomy_get_children($dist_tid, $locations_vid));
$form['baijia_base_locations']['und']['#prefix'] = '<div id="replace_element_div1">';
$form['baijia_base_locations']['und']['#suffix'] = '</div>';
}
function dist_ajax_callback($form, $form_state) {
return $form['baijia_base_locations']['und'];
}
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot.png | 33.23 KB | jerrydqcn |
Comments
Comment #1
rfayComment #2
mdupontThe error seems to be in the file.module
Comment #3
jerrydqcn commentedI solved this problem by adding following to the form validator:
Comment #4
pfrenssen