Hello.
I have form alter function, that adds 'select' element with AJAX function and an imagefield. Goal is to load node's images into imagefield depending of node number selected in 'select' element. It's like node edit form, but with a bit of AJAX.
So, I tried to get it with _field_invoke like this:
if($flag) {
$form['product']['uc_product_image'] = $form['uc_product_image'];
unset($form['uc_product_image']);
$field_name = variable_get('uc_image_' . $node->type, 'uc_product_image');
$options = array('language' => field_valid_language($node->language), 'default' => TRUE, 'field_name' => $field_name);
$form['product'][$field_name] = (array) _field_invoke('form', 'node', $node, $form, $form_state, $options);
$form['product'][$field_name]['#weight'] = 2;
} else {
$form['product']['uc_product_image'] = $form['uc_product_image'];
unset($form['uc_product_image']);
}
But I got this:
Warning: Invalid argument supplied for foreach() в функции file_field_widget_form() (строка 462 в файле X:\home\kaljan.test\www\modules\file\file.field.inc).
Warning: array_values() [function.array-values]: The argument should be an array в функции file_field_widget_form() (строка 471 в файле X:\home\kaljan.test\www\modules\file\file.field.inc).