### Eclipse Workspace Patch 1.0
#P drupal_HEAD
Index: modules/field/modules/list/list.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/list/list.module,v
retrieving revision 1.33
diff -u -r1.33 list.module
--- modules/field/modules/list/list.module	14 Jun 2010 15:41:02 -0000	1.33
+++ modules/field/modules/list/list.module	2 Sep 2010 07:30:49 -0000
@@ -34,7 +34,7 @@
     'list_boolean' => array(
       'label' => t('Boolean'),
       'description' => t('This field stores simple on/off or yes/no options.'),
-      'settings' => array('allowed_values' => '', 'allowed_values_function' => ''),
+      'settings' => array('allowed_values' => '', 'allowed_values_function' => '', 'display_label' => 0, ),
       'default_widget' => 'options_buttons',
       'default_formatter' => 'list_default',
     ),
@@ -129,6 +129,12 @@
       '#value_callback' => 'list_boolean_allowed_values_callback',
       '#access' => empty($settings['allowed_values_function']),
     );
+    $form['display_label'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Use field label instead the "On value" as label'),
+      '#default_value' => $settings['display_label'],
+      '#weight' => -1,
+    );
     $form['allowed_values']['on'] = array(
       '#type' => 'textfield',
       '#title' => t('On value'),
@@ -386,4 +392,4 @@
   }
 
   return $element;
-}
+}
\ No newline at end of file
Index: modules/field/modules/list/tests/list.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/list/tests/list.test,v
retrieving revision 1.7
diff -u -r1.7 list.test
--- modules/field/modules/list/tests/list.test	5 Aug 2010 23:53:37 -0000	1.7
+++ modules/field/modules/list/tests/list.test	2 Sep 2010 07:30:49 -0000
@@ -113,12 +113,12 @@
     parent::setUp('field_test', 'field_ui');
 
     // Create test user.
-    $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy'));
+    $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy', ));
     $this->drupalLogin($admin_user);
 
     // Create content type, with underscores.
     $type_name = 'test_' . strtolower($this->randomName());
-    $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+    $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name, ));
     $this->type = $type->type;
     // Store a valid URL name, with hyphens instead of underscores.
     $this->hyphen_type = str_replace('_', '-', $this->type);
@@ -137,21 +137,21 @@
     //Test 'List' field type.
     $admin_path = $this->createListFieldAndEdit('list');
     //Check that non-integer keys are rejected.
-    $edit = array($element_name => "1.1|one\n");
+    $edit = array($element_name => "1.1|one\n", );
     $this->drupalPost($admin_path, $edit, t('Save settings'));
     $this->assertText("keys must be integers", t('Form validation failed.'));
 
     // Test 'List (number)' field type.
     $admin_path = $this->createListFieldAndEdit('list_number');
     //Check that non-numeric keys are rejected.
-    $edit = array($element_name => "1|one\nB|two");
+    $edit = array($element_name => "1|one\nB|two", );
     $this->drupalPost($admin_path, $edit, t('Save settings'));
     $this->assertText("each key must be a valid integer or decimal", t('Form validation failed.'));
 
     //Test 'List (text)' field type.
     $admin_path = $this->createListFieldAndEdit('list_text');
     //Check that over long keys are rejected.
-    $edit = array($element_name => "1|one\n" . $this->randomName(256) . "|two");
+    $edit = array($element_name => "1|one\n" . $this->randomName(256) . "|two", );
     $this->drupalPost($admin_path, $edit, t('Save settings'));
     $this->assertText("each key must be a string at most 255 characters long", t('Form validation failed.'));
   }
@@ -183,3 +183,128 @@
 
 }
 
+/**
+* List module setting tests
+*
+* Tests if the settings work as expected
+*/
+class ListFieldSettingsTestCase extends FieldTestCase {
+
+  /**
+   * Holds the generic fieldname
+   * @var string
+   */
+  private $_field_name;
+
+  /**
+   * Return information about ths test
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'List field settings',
+      'description' => 'Test the list field settings functionality.',
+      'group' => 'Field types',
+    );
+  }
+
+  /**
+   * @see modules/field/tests/FieldTestCase#setUp()
+   */
+  function setUp() {
+    parent::setUp('field_test', 'field_ui');
+
+    // Create test user.
+    $admin_user = $this->drupalCreateUser(array(
+      'access content',
+      'administer content types',
+      'administer taxonomy',
+    ));
+    $this->drupalLogin($admin_user);
+
+    // Create content type, with underscores.
+    $type_name = 'test_' . strtolower($this->randomName());
+    $type = $this->drupalCreateContentType(array(
+      'name' => $type_name,
+      'type' => $type_name,
+    ));
+    $this->type = $type->type;
+    // Store a valid URL name, with hyphens instead of underscores.
+    $this->hyphen_type = str_replace('_', '-', $this->type);
+
+    // Create random field name.
+    $this->_field_name = strtolower($this->randomName());
+  }
+
+  /**
+   * Tests that the display_label setting is available and
+   * works as expected
+   */
+  function testSettingsDisplayLabel() {
+
+    $this->_createListBooleanFieldAndEdit(); //Create field instance
+    $admin_path = $this->_getTheAdminPath(); //Get the path to the field edit page
+
+    $this->drupalPost($admin_path, array(), t('Save settings'));//Save default Settings
+
+    //Go again to the edit page and check if the default settings work as expected
+    $this->drupalGet($admin_path);
+    $this->assertText(
+      "Use field label instead the \"On value\" as label ",
+      t('Display setting checkbox available.')
+    );
+    $this->assertRaw('>1 </label>', t('Default case shows "On value"'));
+
+    //Enable setting
+    $edit = array('field[settings][display_label]' => 1, );
+    $this->drupalPost($admin_path, $edit, t('Save settings'));//Save the new Settings
+
+    //Go again to the edit page and check if the setting is stored and has the expected effect
+    $this->drupalGet($admin_path);
+    $this->assertText(
+      "Use field label instead the \"On value\" as label ",
+      t('Display setting checkbox is available')
+    );
+    $this->assertFieldChecked(
+      'edit-field-settings-display-label',
+      t('Display settings checkbox checked')
+    );
+    $this->assertRaw(
+      '>' . $this->_field_name . ' </label>',
+      t('Display label changes label of the checkbox')
+    );
+  }
+
+  /**
+   * Helper function to create list field of a given type and get the edit page.
+   * Select the appropriate widget for the test
+   */
+  private function _createListBooleanFieldAndEdit() {
+    // Create a test field and instance.
+    $field = array(
+      'field_name' => $this->_field_name,
+      'type' => 'list_boolean',
+    );
+    field_create_field($field);
+    $instance = array(
+      'field_name' => $this->_field_name,
+      'entity_type' => 'node',
+      'bundle' => $this->type,
+      'widget' => array(
+            'type' => 'options_onoff',
+            'module' => 'options',
+        ),
+    );
+    field_create_instance($instance);
+  }
+
+  /**
+   * Returns the url to the edit page of the current $this->_field_name
+   */
+  private function _getTheAdminPath() {
+    $admin_path = 'admin/structure/types/manage/' .
+      $this->hyphen_type . '/fields/' . $this->_field_name;
+
+    return $admin_path;
+  }
+
+}
Index: modules/field/modules/options/options.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/options/options.module,v
retrieving revision 1.27
diff -u -r1.27 options.module
--- modules/field/modules/options/options.module	17 Aug 2010 21:48:39 -0000	1.27
+++ modules/field/modules/options/options.module	2 Sep 2010 07:30:49 -0000
@@ -122,6 +122,10 @@
       );
       // Override the title from the incoming $element.
       $element['#title'] = isset($options[$on_value]) ? $options[$on_value] : '';
+      
+      if ($field['settings']['display_label']) {
+        $element['#title'] = $instance['label'];
+      }
       break;
   }
 
