Index: modules/image/image.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.field.inc,v
retrieving revision 1.2
diff -u -r1.2 image.field.inc
--- modules/image/image.field.inc	17 Oct 2009 02:14:52 -0000	1.2
+++ modules/image/image.field.inc	30 Oct 2009 23:48:02 -0000
@@ -305,8 +305,8 @@
 /**
  * Implementation of hook_field_widget().
  */
-function image_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
-  $elements = file_field_widget($form, $form_state, $field, $instance, $items, $delta);
+function image_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
+  $elements = file_field_widget($form, $form_state, $field, $instance, $langcode, $items, $delta, $base);
   $settings = $instance['settings'];
 
   foreach (element_children($elements) as $delta) {
Index: modules/file/file.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.field.inc,v
retrieving revision 1.7
diff -u -r1.7 file.field.inc
--- modules/file/file.field.inc	15 Oct 2009 12:44:36 -0000	1.7
+++ modules/file/file.field.inc	30 Oct 2009 23:48:02 -0000
@@ -429,7 +429,7 @@
 /**
  * Implementation of hook_field_widget().
  */
-function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
+function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
   $defaults = array(
@@ -463,8 +463,8 @@
   $element_info = element_info('managed_file');
   $element = array(
     '#type' => 'managed_file',
+    '#required' => $base['#required'],
     '#default_value' => isset($items[$delta]) ? $items[$delta] : $defaults,
-    '#required' => $instance['required'],
     '#upload_location' => file_field_widget_uri($field, $instance),
     '#upload_validators' => file_field_widget_upload_validators($field, $instance),
     '#value_callback' => 'file_field_widget_value',
@@ -479,9 +479,9 @@
 
   if ($field['cardinality'] == 1) {
     // If there's only one field, return it as delta 0.
-    $element['#title'] = $instance['label'];
+    $element['#title'] = $base['#title'];
     if (empty($element['#default_value']['fid'])) {
-      $element['#description'] = theme('file_upload_help', array('description' => $instance['description'], 'upload_validators' => $element['#upload_validators']));
+      $element['#description'] = theme('file_upload_help', array('description' => $base['#description'], 'upload_validators' => $element['#upload_validators']));
     }
     $elements = array($element);
   }
@@ -499,7 +499,7 @@
       $elements[$delta] = $element;
       $elements[$delta]['#default_value'] = $defaults;
       $elements[$delta]['#weight'] = $delta;
-      $elements[$delta]['#required'] = ($instance['required'] && $delta == 0);
+      $elements[$delta]['#required'] = ($base['#required'] && $delta == 0);
     }
     // The group of elements all-together need some extra functionality
     // after building up the full list (like draggable table rows).
@@ -508,8 +508,11 @@
     $elements['#theme_wrappers'] = array('fieldset');
     $elements['#attributes']['class'] = array('file-widget');
     $elements['#process'] = array('file_field_widget_process_multiple');
-    $elements['#title'] = $instance['label'];
-    $elements['#description'] = $instance['description'];
+    $elements['#title'] = $base['#title'];
+    $elements['#description'] = $base['#description'];
+    $elements['#field_name'] = $field['field_name'];
+    $elements['#bundle'] = $instance['bundle'];
+    $elements['#object_type'] = $instance['object_type'];
 
     // 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
Index: modules/field/modules/options/options.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/options/options.module,v
retrieving revision 1.14
diff -u -r1.14 options.module
--- modules/field/modules/options/options.module	23 Oct 2009 22:24:13 -0000	1.14
+++ modules/field/modules/options/options.module	30 Oct 2009 23:48:00 -0000
@@ -94,11 +94,15 @@
 /**
  * Implement hook_field_widget().
  */
-function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
+function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     '#type' => $instance['widget']['type'],
     '#default_value' => !empty($items) ? $items : array(),
-  );
+    '#field_name' => $field['field_name'],
+    '#object_type' => $instance['object_type'],
+    '#bundle' => $instance['bundle'],
+    '#columns' => array_keys($field['columns']),
+  ) + $base;
   return $element;
 }
 
Index: modules/field/field.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v
retrieving revision 1.46
diff -u -r1.46 field.api.php
--- modules/field/field.api.php	23 Oct 2009 22:24:13 -0000	1.46
+++ modules/field/field.api.php	30 Oct 2009 23:47:59 -0000
@@ -632,10 +632,13 @@
  *   Array of default values for this field.
  * @param $delta
  *   The order of this item in the array of subelements (0, 1, 2, etc).
+ * @param $base
+ *   An array containing Form API properties that the form element should reflect:
+ *   #title, #description and #required.
  * @return
  *   The form item for a single element for this field.
  */
-function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
+function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     '#type' => $instance['widget']['type'],
     '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
Index: modules/field/field.form.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v
retrieving revision 1.29
diff -u -r1.29 field.form.inc
--- modules/field/field.form.inc	15 Oct 2009 12:44:34 -0000	1.29
+++ modules/field/field.form.inc	30 Oct 2009 23:47:59 -0000
@@ -57,18 +57,12 @@
     $delta = isset($get_delta) ? $get_delta : 0;
     $function = $instance['widget']['module'] . '_field_widget';
     if (function_exists($function)) {
-      if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
-        $defaults = array(
-          '#required' => $get_delta > 0 ? FALSE : $instance['required'],
-          '#columns'  => array_keys($field['columns']),
-          '#title' => check_plain(t($instance['label'])),
-          '#description' => field_filter_xss($instance['description']),
-          '#delta' => $delta,
-          '#field_name' => $field['field_name'],
-          '#bundle' => $instance['bundle'],
-          '#object_type' => $instance['object_type'],
-        );
-        $element = array_merge($element, $defaults);
+      $base = array(
+        '#title' => check_plain(t($instance['label'])),
+        '#description' => field_filter_xss($instance['description']),
+        '#required' => $get_delta > 0 ? FALSE : $instance['required'],
+      );
+      if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $base)) {
         // If we're processing a specific delta value for a field where the
         // field module handles multiples, set the delta in the result.
         // For fields that handle their own processing, we can't make assumptions
@@ -84,14 +78,6 @@
   }
 
   if ($form_element) {
-    $defaults = array(
-      '#field_name' => $field['field_name'],
-      '#tree' => TRUE,
-      '#weight' => $instance['widget']['weight'],
-    );
-
-    $form_element = array_merge($form_element, $defaults);
-
     // 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
@@ -99,7 +85,7 @@
     // form element.
     $addition[$field['field_name']] = array(
       '#tree' => TRUE,
-      '#weight' => $form_element['#weight'],
+      '#weight' => $instance['widget']['weight'],
       '#language' => $langcode,
       $langcode => $form_element,
     );
@@ -153,26 +139,22 @@
     '#prefix' => '<div id="' . $wrapper_id . '">',
     '#suffix' => '</div>',
     '#max_delta' => $max,
+    '#field_name' => $field['field_name'],
   );
 
   $function = $instance['widget']['module'] . '_field_widget';
   if (function_exists($function)) {
     for ($delta = 0; $delta <= $max; $delta++) {
-      if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
-        $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
-        $defaults = array(
-          // For multiple fields, title and description are handled by the wrapping table.
-          '#title' => $multiple ? '' : $title,
-          '#description' => $multiple ? '' : $description,
-          '#required' => $delta == 0 && $instance['required'],
-          '#weight' => $delta,
-          '#delta' => $delta,
-          '#columns' => array_keys($field['columns']),
-          '#field_name' => $field_name,
-          '#object_type' => $instance['object_type'],
-          '#bundle' => $instance['bundle'],
-        );
-
+      $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
+      $base = array(
+        // For multiple fields, title and description are handled by the wrapping table.
+        '#title' => $multiple ? '' : $title,
+        '#description' => $multiple ? '' : $description,
+        // Only the first widget should be required.
+        '#required' => $delta == 0 && $instance['required'],
+      );
+      if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $base)) {
+        $element['#weight'] = $delta;
         // Input field for the delta (drag-n-drop reordering).
         if ($multiple) {
           // We name the element '_weight' to avoid clashing with elements
@@ -185,14 +167,12 @@
             '#weight' => 100,
           );
         }
-
-        $form_element[$delta] = array_merge($element, $defaults);
+        $form_element[$delta] = $element;
       }
     }
 
     // Add 'add more' button, if not working with a programmed form.
     if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
-
       $form_element[$field_name . '_add_more'] = array(
         '#type' => 'submit',
         '#name' => $field_name . '_add_more',
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.34
diff -u -r1.34 text.module
--- modules/field/modules/text/text.module	23 Oct 2009 22:24:13 -0000	1.34
+++ modules/field/modules/text/text.module	30 Oct 2009 23:48:01 -0000
@@ -563,43 +563,15 @@
 
 /**
  * Implement hook_field_widget().
- *
- * Attach a single form element to the form. It will be built out and
- * validated in the callback(s) listed in hook_element_info(). We build it
- * out in the callbacks rather than here in hook_field_widget so it can be
- * plugged into any module that can provide it with valid
- * $field information.
- *
- * Field module will set the weight, field name and delta values
- * for each form element.
- *
- * If there are multiple values for this field, the field module will
- * call this function as many times as needed.
- *
- * @param $form
- *   the entire form array, $form['#node'] holds node information
- * @param $form_state
- *   the form_state, $form_state['values'][$field['field_name']]
- *   holds the field's form values.
- * @param $field
- *   The field structure.
- * @param $instance
- *   the field instance array
- * @param $langcode
- *   The language associated to $items.
- * @param $items
- *   array of default values for this field
- * @param $delta
- *   the order of this item in the array of subelements (0, 1, 2, etc)
- *
- * @return
- *   the form item for a single element for this field
  */
-function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
+function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     '#type' => $instance['widget']['type'],
     '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
-  );
+    '#field_name' => $field['field_name'],
+    '#columns' => array_keys($field['columns']),
+    '#delta' => $delta,
+  ) + $base;
   if (!empty($instance['settings']['text_processing'])) {
     $element['#value_callback'] = 'text_field_widget_formatted_text_value';
   }
Index: modules/field/modules/number/number.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.module,v
retrieving revision 1.23
diff -u -r1.23 number.module
--- modules/field/modules/number/number.module	23 Oct 2009 22:24:13 -0000	1.23
+++ modules/field/modules/number/number.module	30 Oct 2009 23:47:59 -0000
@@ -313,40 +313,17 @@
 
 /**
  * Implement hook_field_widget().
- *
- * Attach a single form element to the form. It will be built out and
- * validated in the callback(s) listed in hook_element_info(). We build it
- * out in the callbacks rather than here in hook_widget so it can be
- * plugged into any module that can provide it with valid
- * $field information.
- *
- * Field module will set the weight, field name and delta values
- * for each form element.
- *
- * If there are multiple values for this field, the Field module will
- * call this function as many times as needed.
- *
- * @param $form
- *   the entire form array, $form['#node'] holds node information
- * @param $form_state
- *   the form_state, $form_state['values'] holds the form values.
- * @param $field
- *   The field structure.
- * @param $instance
- *   the field instance array
- * @param $langcode
- *   The language associated to $items.
- * @param $delta
- *   the order of this item in the array of subelements (0, 1, 2, etc)
- *
- * @return
- *   the form item for a single element for this field
  */
-function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
+function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     '#type' => $instance['widget']['type'],
     '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
-  );
+    '#field_name' => $field['field_name'],
+    '#object_type' => $instance['object_type'],
+    '#bundle' => $instance['bundle'],
+    '#columns' => array_keys($field['columns']),
+    '#delta' => $delta,
+  ) + $base;
   return $element;
 }
 
Index: modules/simpletest/tests/field_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/field_test.module,v
retrieving revision 1.35
diff -u -r1.35 field_test.module
--- modules/simpletest/tests/field_test.module	24 Oct 2009 17:02:51 -0000	1.35
+++ modules/simpletest/tests/field_test.module	30 Oct 2009 23:48:03 -0000
@@ -489,41 +489,13 @@
 
 /**
  * Implement hook_field_widget().
- *
- * Attach a single form element to the form. It will be built out and
- * validated in the callback(s) listed in hook_element_info(). We build it
- * out in the callbacks rather than here in hook_widget so it can be
- * plugged into any module that can provide it with valid
- * $field information.
- *
- * If there are multiple values for this field, the field module will
- * call this function as many times as needed.
- *
- * @param $form
- *   the entire form array, $form['#node'] holds node information
- * @param $form_state
- *   the form_state, $form_state['values'][$field['field_name']]
- *   holds the field's form values.
- * @param $field
- *   The field structure.
- * @param $instance
- *   the instance array
- * @param $items
- *   array of default values for this field
- * @param $delta
- *   the order of this item in the array of subelements (0, 1, 2, etc)
- *
- * @return
- *   the form item for a single element for this field
  */
-function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
+function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     'value' => array(
-      '#title' => $instance['label'],
       '#type' => 'textfield',
       '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
-      '#required' => $instance['required'],
-    ),
+    ) + $base,
   );
   return $element;
 }
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.530
diff -u -r1.530 taxonomy.module
--- modules/taxonomy/taxonomy.module	24 Oct 2009 05:13:44 -0000	1.530
+++ modules/taxonomy/taxonomy.module	30 Oct 2009 23:48:05 -0000
@@ -1211,11 +1211,14 @@
 /**
  * Implement hook_field_widget().
  */
-function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
+function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
   $element = array(
     '#type' => $instance['widget']['type'],
     '#default_value' => !empty($items) ? $items : array(),
-  );
+    '#field_name' => $field['field_name'],
+    '#bundle' => $instance['bundle'],
+    '#columns' => array_keys($field['columns']),
+  ) + $base;
   return $element;
 }
 
