Index: modules/field/field.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v retrieving revision 1.59 diff -u -p -r1.59 field.api.php --- modules/field/field.api.php 2 Jan 2010 15:00:34 -0000 1.59 +++ modules/field/field.api.php 4 Jan 2010 19:41:48 -0000 @@ -609,15 +609,16 @@ function hook_field_widget_info_alter(&$ * contains the base form element properties derived from the field * configuration. * - * Field API will set the weight, field name and delta values for each - * form element. If there are multiple values for this field, the - * Field API will call this function as many times as needed. + * @todo note about $form_state['field'] + * + * Field API will set the weight, field name and delta values for each form + * element. If there are multiple values for this field, the Field API will + * call this function as many times as needed. * * @param $form * The entire form array. * @param $form_state - * The form_state, $form_state['values'][$field['field_name']] - * holds the field's form values. + * An associative array containing the current state of the form. * @param $field * The field structure. * @param $instance @@ -633,6 +634,7 @@ function hook_field_widget_info_alter(&$ * - #object_type: The name of the object the field is attached to. * - #bundle: The name of the field bundle the field is contained in. * - #field_name: The name of the field. + * - #language: The language the field is being edited in. * - #columns: A list of field storage columns of the field. * - #title: The sanitized element label for the field instance, ready for * output. @@ -643,7 +645,6 @@ function hook_field_widget_info_alter(&$ * required. * - #delta: The order of this item in the array of subelements; see $delta * above. - * * @return * The form elements for a single widget for this field. */ @@ -668,8 +669,12 @@ function hook_field_widget_form(&$form, * - 'error': the error code. Complex widgets might need to report different * errors to different form elements inside the widget. * - 'message': the human readable message to be displayed. + * @param $form + * The form array. + * @param $form_state + * An associative array containing the current state of the form. */ -function hook_field_widget_error($element, $error) { +function hook_field_widget_error($element, $error, $form, &$form_state) { form_error($element['value'], $error['message']); } Index: modules/field/field.attach.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.attach.inc,v retrieving revision 1.71 diff -u -p -r1.71 field.attach.inc --- modules/field/field.attach.inc 4 Jan 2010 15:56:28 -0000 1.71 +++ modules/field/field.attach.inc 4 Jan 2010 19:41:48 -0000 @@ -414,21 +414,10 @@ function _field_invoke_multiple_default( * is provided the default site language will be used. * @return * The form elements are added by reference at the top level of the $form - * parameter. Sample structure: + * parameter. Processing information is added by reference in + * $form_state['field']. + * Sample structure for $form: * @code - * array( - * '#fields' => array( - * // One sub-array per field appearing in the form, keyed by field name. - * 'field_foo' => array ( - * 'field' => the field definition structure, - * 'instance' => the field instance definition structure, - * 'form_path' => an array of keys indicating the path to the field - * element within the full $form structure, used by the 'add more - * values' AHAH button. Any 3rd party module using form_alter() to - * modify the structure of the form should update this entry as well. - * ), - * ), - * * // One sub-array per field appearing in the form, keyed by field name. * // The structure of the array differs slightly depending on whether the * // widget is 'single-value' (provides the input for one field value, @@ -436,12 +425,12 @@ function _field_invoke_multiple_default( * // needed, or 'multiple-values' (one single widget allows the input of * // several values, e.g checkboxes, select box...). * // The sub-array is nested into a $langcode key where $langcode has the - * // same value of the $langcode parameter above. This allow us to match - * // the field data structure ($field_name[$langcode][$delta][$column]). + * // same value of the $langcode parameter above. * // The '#language' key holds the same value of $langcode and it is used * // to access the field sub-array when $langcode is unknown. * 'field_foo' => array( * '#tree' => TRUE, + * '#field_name' => the name of the field * '#language' => $langcode, * $langcode => array( * '#field_name' => the name of the field, @@ -481,6 +470,26 @@ function _field_invoke_multiple_default( * ), * ) * @endcode + * + * Sample structure for $form_state['field']: @todo + * @code + * array( + * // One sub-array per field appearing in the form, keyed by field name. + * 'field_foo' => array ( + * // One sub-array per language the field is being edited in. + * // @todo compare with above. + * 'xxz' => array ( + * 'field' => the field definition structure, + * 'instance' => the field instance definition structure, + * 'parents' => @todo + * 'array_parents' => @todo an array of keys indicating the path to the field + * element within the full $form structure, used by the 'add more + * values' AHAH button. + * 'errors' => @todo + * ), + * ), + * ), + * */ function field_attach_form($obj_type, $object, &$form, &$form_state, $langcode = NULL) { // If no language is provided use the default site language. @@ -748,7 +757,12 @@ function field_attach_form_validate($obj catch (FieldValidationException $e) { // Pass field-level validation errors back to widgets for accurate error // flagging. - _field_invoke_default('form_errors', $obj_type, $object, $form, $e->errors); + foreach ($e->errors as $field_name => $field_errors) { + foreach ($field_errors as $langcode => $language_errors) { + $form_state['field'][$field_name][$langcode]['errors'] = $language_errors; + } + } + _field_invoke_default('form_errors', $obj_type, $object, $form, $form_state); } } Index: modules/field/field.form.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v retrieving revision 1.39 diff -u -p -r1.39 field.form.inc --- modules/field/field.form.inc 2 Jan 2010 23:30:53 -0000 1.39 +++ modules/field/field.form.inc 4 Jan 2010 19:41:48 -0000 @@ -17,16 +17,16 @@ function field_default_form($obj_type, $ } $field_name = $field['field_name']; + $addition[$field_name] = array(); - // Put field information at the top of the form, so that it can be easily - // retrieved. - // Note : widgets and other form handling code should *always* fetch field - // and instance information from $form['#fields'] rather than from - // field_info_field(). This lets us build forms for 'variants' of a field, - // for instance on admin screens. - $form['#fields'][$field_name] = array( + // Store field information in $form_state['storage']. + $form_state['field'][$field_name][$langcode] = array( 'field' => $field, 'instance' => $instance, + // This entry will be populated at form build time. + 'array_parents' => array(), + // This entry will be populated at form validation time. + 'errors' => array(), ); // Populate widgets with default values when creating a new object. @@ -34,13 +34,13 @@ function field_default_form($obj_type, $ $items = field_get_default_value($obj_type, $object, $field, $instance, $langcode); } - $field_elements = array(); - + // Collect widget elements. + $elements = array(); if (field_access('edit', $field, $obj_type, $object)) { // If field module handles multiple values for this form element, and we // are displaying an individual element, process the multiple value form. if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) { - $field_elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state); + $elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state); } // If the widget is handling multiple values (e.g Options), or if we are // displaying an individual element, just get a single form element and @@ -53,6 +53,7 @@ function field_default_form($obj_type, $ '#object_type' => $instance['object_type'], '#bundle' => $instance['bundle'], '#field_name' => $field_name, + '#language' => $langcode, '#columns' => array_keys($field['columns']), '#title' => check_plain(t($instance['label'])), '#description' => field_filter_xss($instance['description']), @@ -67,23 +68,17 @@ function field_default_form($obj_type, $ // assumptions about how the field is structured, just merge in the // returned element. if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) { - $field_elements[$delta] = $element; + $elements[$delta] = $element; } else { - $field_elements = $element; + $elements = $element; } } } } } - if ($field_elements) { - // Add the field form element as a child keyed by language code to match - // the field data structure: - // $object->{$field_name}[$langcode][$delta][$column]. - // The '#language' key can be used to access the field's form element - // when $langcode is unknown. The #weight property is inherited from the - // field's form element. + if ($elements) { // Also aid in theming of field widgets by rendering a classified // container. $addition[$field_name] = array( @@ -95,29 +90,32 @@ function field_default_form($obj_type, $ 'field-widget-' . drupal_html_class($instance['widget']['type']), ), ), - '#tree' => TRUE, '#weight' => $instance['widget']['weight'], - '#language' => $langcode, - $langcode => $field_elements, ); } else { // The field is not accessible, or the widget did not return anything. Make // sure the items are available in the submitted form values. foreach ($items as $delta => $item) { - $field_elements[$delta] = array( + $elements[$delta] = array( '#type' => 'value', '#value' => $item, ); } - $addition[$field_name] = array( - '#tree' => TRUE, - '#language' => $langcode, - $langcode => $field_elements, - ); } - $form['#fields'][$field_name]['form_path'] = array($field_name); + // @todo A word of explanation. + $elements['#after_build'][] = 'field_form_element_after_build'; + $elements['#field_name'] = $field_name; + $elements['#language'] = $langcode; + + $addition[$field_name] += array( + '#tree' => TRUE, + // The '#language' key can be used to access the field's form element + // when $langcode is unknown. + '#language' => $langcode, + $langcode => $elements, + ); return $addition; } @@ -158,7 +156,7 @@ function field_multiple_value_form($fiel $title = check_plain(t($instance['label'])); $description = field_filter_xss(t($instance['description'])); - $wrapper_id = drupal_html_class($field_name) . '-wrapper'; + $wrapper_id = drupal_html_class($field_name) . '-add-more-wrapper'; $field_elements = array(); $function = $instance['widget']['module'] . '_field_widget_form'; @@ -169,6 +167,7 @@ function field_multiple_value_form($fiel '#object_type' => $instance['object_type'], '#bundle' => $instance['bundle'], '#field_name' => $field_name, + '#language' => $langcode, '#columns' => array_keys($field['columns']), // For multiple fields, title and description are handled by the wrapping table. '#title' => $multiple ? '' : $title, @@ -304,36 +303,54 @@ function theme_field_multiple_value_form return $output; } +/** + * Stores information about the built form structure in the form storage. + * + * The 'array_parents' array is used to assign validation errors to actual form + * elements, and to identify the form element to return in the AJAX 'add more' + * button handler. + * @see field_default_form_errors() + * @see field_add_more_js() + */ +function field_form_element_after_build($element, &$form_state) { + $field_name = $element['#field_name']; + $langcode = $element['#language']; + $form_state['field'][$field_name][$langcode]['array_parents'] = $element['#array_parents']; + + return $element; +} /** * Transfer field-level validation errors to widgets. */ -function field_default_form_errors($obj_type, $object, $field, $instance, $langcode, $items, $form, $errors) { +function field_default_form_errors($obj_type, $object, $field, $instance, $langcode, $items, $form, &$form_state) { $field_name = $field['field_name']; - if (!empty($errors[$field_name][$langcode])) { + $field_info = $form_state['field'][$field_name][$langcode]; + // @todo Should we test isset($form_state['field'][$field_name][$langcode]) ? + + if (!empty($field_info['errors'])) { $function = $instance['widget']['module'] . '_field_widget_error'; $function_exists = function_exists($function); // Walk the form down to where the widget lives. - $form_path = $form['#fields'][$field_name]['form_path']; $element = $form; - foreach ($form_path as $key) { + foreach ($field_info['array_parents'] as $key) { $element = $element[$key]; } $multiple_widget = field_behaviors_widget('multiple values', $instance) != FIELD_BEHAVIOR_DEFAULT; - foreach ($errors[$field_name][$langcode] as $delta => $delta_errors) { + foreach ($field_info['errors'] as $delta => $delta_errors) { // For multiple single-value widgets, pass errors by delta. // For a multiple-value widget, all errors are passed to the main widget. - $error_element = $multiple_widget ? $element[$langcode] : $element[$langcode][$delta]; + $error_element = $multiple_widget ? $element : $element[$delta]; foreach ($delta_errors as $error) { if ($function_exists) { - $function($error_element, $error); + $function($error_element, $error, $form, $form_state); } else { // Make sure that errors are reported (even incorrectly flagged) if // the widget module fails to implement hook_field_widget_error(). - form_error($error_element, $error['error']); + form_error($error_element, $error['error'], $form, $form_state); } } } @@ -374,22 +391,25 @@ function field_add_more_submit($form, &$ function field_add_more_js($form, $form_state) { // Retrieve field information. $field_name = $form_state['clicked_button']['#field_name']; - $field = $form['#fields'][$field_name]['field']; + $langcode = $form_state['clicked_button']['#language']; + $field_info = $form_state['field'][$field_name][$langcode]; + $field = $field_info['field']; + if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED) { ajax_render(array()); } - // Navigate to the right part of the form. - $form_path = $form['#fields'][$field_name]['form_path']; - $field_form = $form; - foreach ($form_path as $key) { - $field_form = $field_form[$key]; + + // Navigate to the right element in the the form. + $element = $form; + + foreach ($field_info['array_parents'] as $key) { + $element = $element[$key]; } // Add a DIV around the new field to receive the AJAX effect. - $langcode = $field_form['#language']; - $delta = $field_form[$langcode]['#max_delta']; - $field_form[$langcode][$delta]['#prefix'] = '
' . (isset($field_form[$langcode][$delta]['#prefix']) ? $field_form[$langcode][$delta]['#prefix'] : ''); - $field_form[$langcode][$delta]['#suffix'] = (isset($field_form[$langcode][$delta]['#suffix']) ? $field_form[$langcode][$delta]['#suffix'] : '') . '
'; + $delta = $element['#max_delta']; + $element[$delta]['#prefix'] = '
' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : ''); + $element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '
'; - return drupal_render($field_form); + return $element; } Index: modules/field/modules/number/number.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.module,v retrieving revision 1.33 diff -u -p -r1.33 number.module --- modules/field/modules/number/number.module 21 Dec 2009 13:47:32 -0000 1.33 +++ modules/field/modules/number/number.module 4 Jan 2010 19:41:49 -0000 @@ -337,8 +337,8 @@ function number_field_widget_form(&$form * FAPI validation of an individual number element. */ function number_field_widget_validate($element, &$form_state) { - $field = $form_state['complete form']['#fields'][$element['#field_name']]['field']; - $instance = $form_state['complete form']['#fields'][$element['#field_name']]['instance']; + $field = $form_state['field'][$element['#field_name']][$element['#language']]['field']; + $instance = $form_state['field'][$element['#field_name']][$element['#language']]['instance']; $type = $element['#number_type']; $value = $element['#value']; @@ -373,6 +373,6 @@ function number_field_widget_validate($e /** * Implements hook_field_widget_error(). */ -function number_field_widget_error($element, $error) { +function number_field_widget_error($element, $error, $form, &$form_state) { form_error($element['value'], $error['message']); } Index: modules/field/modules/options/options.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/options/options.module,v retrieving revision 1.23 diff -u -p -r1.23 options.module --- modules/field/modules/options/options.module 21 Dec 2009 13:47:32 -0000 1.23 +++ modules/field/modules/options/options.module 4 Jan 2010 19:41:49 -0000 @@ -359,7 +359,7 @@ function options_array_flatten($array) { /** * Implements hook_field_widget_error(). */ -function options_field_widget_error($element, $error) { +function options_field_widget_error($element, $error, $form, &$form_state) { form_error($element, $error['message']); } Index: modules/field/modules/text/text.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v retrieving revision 1.45 diff -u -p -r1.45 text.module --- modules/field/modules/text/text.module 21 Dec 2009 13:47:32 -0000 1.45 +++ modules/field/modules/text/text.module 4 Jan 2010 19:41:49 -0000 @@ -566,7 +566,7 @@ function text_field_widget_form(&$form, /** * Implements hook_field_widget_error(). */ -function text_field_widget_error($element, $error) { +function text_field_widget_error($element, $error, $form, &$form_state) { switch ($error['error']) { case 'text_summary_max_length': $error_element = $element[$element['#columns'][1]]; Index: modules/field/tests/field.test =================================================================== RCS file: /cvs/drupal/drupal/modules/field/tests/field.test,v retrieving revision 1.10 diff -u -p -r1.10 field.test --- modules/field/tests/field.test 26 Dec 2009 16:50:08 -0000 1.10 +++ modules/field/tests/field.test 4 Jan 2010 19:41:49 -0000 @@ -1148,6 +1148,9 @@ class FieldAttachOtherTestCase extends F $values[1]['value'] = 0; $langcode = LANGUAGE_NONE; + // Pretend the form has been built. + drupal_prepare_form('field_test_entity_form', $form, $form_state); + $form = form_builder('field_test_entity_form', $form, $form_state); $form_state['values'] = array($this->field_name => array($langcode => $values)); field_attach_submit($entity_type, $entity, $form, $form_state); Index: modules/field/tests/field_test.field.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/tests/field_test.field.inc,v retrieving revision 1.6 diff -u -p -r1.6 field_test.field.inc --- modules/field/tests/field_test.field.inc 21 Dec 2009 13:47:32 -0000 1.6 +++ modules/field/tests/field_test.field.inc 4 Jan 2010 19:43:44 -0000 @@ -194,7 +194,7 @@ function field_test_widget_multiple_vali /** * Implements hook_field_widget_error(). */ -function field_test_field_widget_error($element, $error) { +function field_test_field_widget_error($element, $error, $form, &$form_state) { // @todo No easy way to differenciate widget types, we should receive it as a // parameter. if (isset($element['value'])) { Index: modules/field_ui/field_ui.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v retrieving revision 1.35 diff -u -p -r1.35 field_ui.admin.inc --- modules/field_ui/field_ui.admin.inc 3 Jan 2010 21:01:04 -0000 1.35 +++ modules/field_ui/field_ui.admin.inc 4 Jan 2010 19:41:49 -0000 @@ -1205,6 +1205,7 @@ function field_ui_default_value_widget($ '#collapsible' => FALSE, '#tree' => TRUE, '#description' => t('The default value for this field, used when creating new content.'), + '#parents' => array(), ); // Insert the widget. @@ -1214,10 +1215,6 @@ function field_ui_default_value_widget($ // @todo Allow multiple values (requires more work on 'add more' JS handler). $element += field_default_form(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state, 0); - // Adjust 'form_path' to reflect the actual location of the widget in the - // form structure. - $form['#fields'][$field_name]['form_path'] = array('instance', 'default_value_widget', $field_name); - return $element; } @@ -1226,25 +1223,22 @@ function field_ui_default_value_widget($ */ function field_ui_field_edit_form_validate($form, &$form_state) { $instance = $form_state['values']['instance']; + $field_name = $instance['field_name']; + $field = field_info_field($field_name); // Validate the default value. - if (!empty($instance['default_value_widget'])) { - $field = field_info_field($instance['field_name']); - - // Extract field values. - $items = array(); - $form_state_copy = array('values' => $instance['default_value_widget']); - field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy); - - // Validate the values and report errors. - $errors = array(); - $function = $field['module'] . '_field_validate'; - if (function_exists($function)) { - $function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors); - } - if ($errors) { - field_default_form_errors(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $errors); - } + // Extract field values. + $items = array(); + field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state); + // Validate the values and report errors. + $errors = array(); + $function = $field['module'] . '_field_validate'; + if (function_exists($function)) { + $function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors); + } + if (isset($errors[$field_name][LANGUAGE_NONE])) { + $form_state['field'][$field_name][LANGUAGE_NONE]['errors'] = $errors[$field_name][LANGUAGE_NONE]; + field_default_form_errors(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state); } } @@ -1261,18 +1255,12 @@ function field_ui_field_edit_form_submit field_update_field($field); // Handle the default value. - if (!empty($instance['default_value_widget'])) { - // Extract field values. - $items = array(); - $form_state_copy = array('values' => $instance['default_value_widget']); - field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy); - - // Prepare field values. - field_default_submit(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy); - - $instance['default_value'] = $items ? $items : NULL; - unset($instance['default_value_widget']); - } + // Extract field values. + $items = array(); + field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state); + // Prepare field values. + field_default_submit(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state); + $instance['default_value'] = $items ? $items : NULL; // Update the instance settings. $instance_source = field_info_instance($instance['object_type'], $instance['field_name'], $instance['bundle']); Index: modules/field_ui/field_ui.test =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.test,v retrieving revision 1.6 diff -u -p -r1.6 field_ui.test --- modules/field_ui/field_ui.test 2 Dec 2009 19:26:22 -0000 1.6 +++ modules/field_ui/field_ui.test 4 Jan 2010 19:41:49 -0000 @@ -236,8 +236,8 @@ class FieldUITestCase extends DrupalWebT $langcode = LANGUAGE_NONE; $admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $field_name; - $element_id = "edit-instance-default-value-widget-$field_name-$langcode-0-value"; - $element_name = "instance[default_value_widget][$field_name][$langcode][0][value]"; + $element_id = "edit-$field_name-$langcode-0-value"; + $element_name = "{$field_name}[$langcode][0][value]"; $this->drupalGet($admin_path); $this->assertFieldById($element_id, '', t('The default value widget was empty.')); Index: modules/file/file.field.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/file/file.field.inc,v retrieving revision 1.15 diff -u -p -r1.15 file.field.inc --- modules/file/file.field.inc 21 Dec 2009 13:47:32 -0000 1.15 +++ modules/file/file.field.inc 4 Jan 2010 19:41:49 -0000 @@ -501,9 +501,9 @@ function file_field_widget_form(&$form, $elements['#process'] = array('file_field_widget_process_multiple'); $elements['#title'] = $element['#title']; $elements['#description'] = $element['#description']; - $elements['#object_type'] = $element['#object_type']; - $elements['#bundle'] = $element['#bundle']; $elements['#field_name'] = $element['#field_name']; + $elements['#language'] = $element['#language']; + $elements['#display_field'] = $field['settings']['display_field']; // Add some properties that will eventually be added to the file upload // field. These are added here so that they may be referenced easily through @@ -571,7 +571,7 @@ function file_field_widget_value($elemen if ($input) { // Checkboxes lose their value when empty. // If the display field is present make sure its unchecked value is saved. - $field = field_info_field($element['#field_name']); + $field = $form_state['field'][$element['#field_name']][$element['#language']]['field']; if (empty($input['display'])) { $input['display'] = $field['settings']['display_field'] ? 0 : 1; } @@ -599,8 +599,8 @@ function file_field_widget_process($elem $item = $element['#value']; $item['fid'] = $element['fid']['#value']; - $field = field_info_field($element['#field_name']); - $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']); + $field = $form_state['field'][$element['#field_name']][$element['#language']]['field']; + $instance = $form_state['field'][$element['#field_name']][$element['#language']]['instance']; $settings = $instance['widget']['settings']; $element['#theme'] = 'file_widget'; @@ -711,9 +711,6 @@ function theme_file_widget($variables) { function theme_file_widget_multiple($variables) { $element = $variables['element']; - $field = field_info_field($element['#field_name']); - $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']); - // Get our list of widgets in order. $widgets = array(); foreach (element_children($element) as $key) { @@ -728,7 +725,7 @@ function theme_file_widget_multiple($var // Build up a table of applicable fields. $headers = array(); $headers[] = t('File information'); - if (!empty($field['settings']['display_field'])) { + if ($element['#display_field']) { $headers[] = array( 'data' => t('Display'), 'class' => array('checkbox'), @@ -756,7 +753,7 @@ function theme_file_widget_multiple($var // Render the "Display" option in its own own column. $display = ''; - if (!empty($field['settings']['display_field'])) { + if ($element['#display_field']) { unset($element[$key]['display']['#title']); $display = array( 'data' => drupal_render($element[$key]['display']), @@ -774,7 +771,7 @@ function theme_file_widget_multiple($var $row = array(); $row[] = $information; - if (!empty($field['settings']['display_field'])) { + if ($element['#display_field']) { $row[] = $display; } $row[] = $weight; Index: modules/image/image.field.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.field.inc,v retrieving revision 1.9 diff -u -p -r1.9 image.field.inc --- modules/image/image.field.inc 21 Dec 2009 13:47:32 -0000 1.9 +++ modules/image/image.field.inc 4 Jan 2010 19:41:49 -0000 @@ -348,8 +348,8 @@ function image_field_widget_process($ele $item = $element['#value']; $item['fid'] = $element['fid']['#value']; - $field = field_info_field($element['#field_name']); - $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']); + $instance = $form_state['field'][$element['#field_name']][$element['#language']]['instance']; + $settings = $instance['settings']; $widget_settings = $instance['widget']['settings']; Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.556 diff -u -p -r1.556 taxonomy.module --- modules/taxonomy/taxonomy.module 4 Jan 2010 18:03:12 -0000 1.556 +++ modules/taxonomy/taxonomy.module 4 Jan 2010 19:41:49 -0000 @@ -1240,7 +1240,7 @@ function taxonomy_autocomplete_validate( // them here and process them independently. if ($tags = $element['#value']) { // Collect candidate vocabularies. - $field = $form_state['complete form']['#fields'][$element['#field_name']]['field']; + $field = $form_state['field'][$element['#field_name']][$element['#language']]['field']; $vids = array(); foreach ($field['settings']['allowed_values'] as $tree) { $vids[] = $tree['vid']; @@ -1278,10 +1278,9 @@ function taxonomy_autocomplete_validate( /** * Implements hook_field_widget_error(). */ -function taxonomy_field_widget_error($element, $error) { +function taxonomy_field_widget_error($element, $error, $form, &$form_state) { form_error($element, $error['message']); } - /** * Implements hook_field_settings_form(). */