 core/includes/form.inc                            |   42 +++++++++++++++-
 core/modules/field/modules/options/options.module |   10 +++-
 core/modules/field/tests/field.test               |   41 +++++++++++++++
 core/modules/simpletest/tests/form.test           |   56 +++++++++++++++++++++
 core/modules/simpletest/tests/form_test.module    |   54 ++++++++++++++++++++
 5 files changed, 201 insertions(+), 2 deletions(-)

diff --git a/core/includes/form.inc b/core/includes/form.inc
index eef5334..139a663 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2241,6 +2241,44 @@ function form_type_checkbox_value($element, $input = FALSE) {
 }
 
 /**
+ * Form value callback: Determines the value for a radio form element.
+ *
+ * @param $element
+ *   The form element whose value is being populated.
+ * @param $input
+ *   (optional) The incoming input to populate the form element. If FALSE, the
+ *   element's default value is returned. Defaults to FALSE.
+ *
+ * @return
+ *   The data that will appear in the $element_state['values'] collection for
+ *   this element.
+ */
+function form_type_radios_value(&$element, $input = FALSE) {
+  // If there is data from a form submission, use that.
+  if ($input !== FALSE) {
+    // Check if the user submission had no value for this element.
+    if (!isset($input)) {
+      // Flag as a garbage value. If the value is set to NULL and
+      // #has_garbage_value is not set then the form builder will automatically
+      // attempt to use default value or '' (an empty string). An empty string
+      // will fail validation because it is not in the allowed values list.
+      $element['#has_garbage_value'] = TRUE;
+      // There was a user submission so validation is a must. This way, the
+      // required checker will produce an error as necessary.
+      $element['#needs_validation'] = TRUE;
+    }
+    // The value stays the same, but the flags above will ensure it is
+    // processed properly.
+    return $input;
+  }
+
+  // When $input is FALSE, return the default if it exists.
+  if (isset($element['#default_value'])) {
+    return $element['#default_value'];
+  }
+}
+
+/**
  * Helper function to determine the value for a checkboxes form element.
  *
  * @param $element
@@ -2956,7 +2994,9 @@ function form_process_radios($element) {
         // The key is sanitized in drupal_attributes() during output from the
         // theme function.
         '#return_value' => $key,
-        '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
+        // Use default or FALSE. A value of FALSE means that the radio button is
+        // not 'checked'.
+        '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : FALSE,
         '#attributes' => $element['#attributes'],
         '#parents' => $element['#parents'],
         '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
diff --git a/core/modules/field/modules/options/options.module b/core/modules/field/modules/options/options.module
index d4d05ec..04b88d8 100644
--- a/core/modules/field/modules/options/options.module
+++ b/core/modules/field/modules/options/options.module
@@ -102,10 +102,18 @@ function options_field_widget_form(&$form, &$form_state, $field, $instance, $lan
         reset($options);
         $default_value = array(key($options));
       }
+
+      // If this is a single-value field, take the first default value, or
+      // default to NULL so that the form element is properly recognized as
+      // not having a default value.
+      if (!$multiple) {
+        $default_value = $default_value ? reset($default_value) : NULL;
+      }
+
       $element += array(
         '#type' => $multiple ? 'checkboxes' : 'radios',
         // Radio buttons need a scalar value.
-        '#default_value' => $multiple ? $default_value : reset($default_value),
+        '#default_value' => $default_value,
         '#options' => $options,
       );
       break;
diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test
index 667bac1..c5b052b 100644
--- a/core/modules/field/tests/field.test
+++ b/core/modules/field/tests/field.test
@@ -1459,6 +1459,47 @@ class FieldFormTestCase extends FieldTestCase {
     // Test with several multiple fields in a form
   }
 
+  function testFieldFormMultivalueWithRequiredRadio() {
+    // Create a multivalue test field.
+    $this->field = $this->field_unlimited;
+    $this->field_name = $this->field['field_name'];
+    $this->instance['field_name'] = $this->field_name;
+    field_create_field($this->field);
+    field_create_instance($this->instance);
+    $langcode = LANGUAGE_NONE;
+
+    // Add a required radio field.
+    field_create_field(array(
+      'field_name' => 'required_radio_test',
+      'type' => 'list_text',
+      'settings' => array(
+        'allowed_values' => array('yes' => 'yes', 'no' => 'no'),
+      ),
+    ));
+    field_create_instance(array(
+      'field_name' => 'required_radio_test',
+      'entity_type' => 'test_entity',
+      'bundle' => 'test_bundle',
+      'required' => TRUE,
+      'widget' => array(
+        'type' => 'options_buttons',
+      ),
+    ));
+
+    // Display creation form.
+    $this->drupalGet('test-entity/add/test-bundle');
+
+    // Press the 'Add more' button.
+    $this->drupalPost(NULL, array(), t('Add another item'));
+
+    // Verify that no error is thrown by the radio element.
+    $this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, t('No error message is displayed.'));
+
+    // Verify that the widget is added.
+    $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget 1 is displayed'));
+    $this->assertFieldByName("{$this->field_name}[$langcode][1][value]", '', t('New widget is displayed'));
+    $this->assertNoField("{$this->field_name}[$langcode][2][value]", t('No extraneous widget is displayed'));
+  }
   function testFieldFormJSAddMore() {
     $this->field = $this->field_unlimited;
     $this->field_name = $this->field['field_name'];
diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test
index 94dfa87..6ffe1ef 100644
--- a/core/modules/simpletest/tests/form.test
+++ b/core/modules/simpletest/tests/form.test
@@ -122,6 +122,62 @@ class FormsTestCase extends DrupalWebTestCase {
   }
 
   /**
+   * Tests validation for required checkbox, select, and radio elements.
+   *
+   * Submits a test form containing several types of form elements. The form
+   * is submitted twice, first without values for required fields and then
+   * with values. Each submission is checked for relevant error messages.
+   *
+   * @see form_test_validate_required_form()
+   */
+  function testRequiredCheckboxesRadio() {
+    $form = $form_state = array();
+    $form = form_test_validate_required_form($form, $form_state);
+
+    // Attempt to submit the form with no required fields set.
+    $edit = array();
+    $this->drupalPost('form-test/validate-required', $edit, t('Submit'));
+
+    // The only error messages that should appear are the relevant 'required'
+    // messages for each field.
+    $expected = array();
+    foreach (array('textfield', 'checkboxes', 'select', 'radios') as $key) {
+      $expected[] = t('!name field is required.', array('!name' => $form[$key]['#title']));
+    }
+
+    // Check the page for error messages.
+    $errors = $this->xpath('//div[contains(@class, "error")]//li');
+    foreach ($errors as $error) {
+      $expected_key = array_search($error[0], $expected);
+      // If the error message is not one of the expected messages, fail.
+      if ($expected_key === FALSE) {
+        $this->fail(t("Invalid error message: !error", array('!error' => $error[0])));
+      }
+      // Remove the expected message from the list once it is found.
+      else {
+        unset($expected[$expected_key]);
+      }
+    }
+
+    // Fail if any expected messages were not found.
+    foreach ($expected as $not_found) {
+      $this->fail(t("Error message not shown: !error", array('!error' => $not_found)));
+    }
+
+    // Submit again with required fields set and verify that there are no
+    // error messages.
+    $edit = array(
+      'textfield' => $this->randomString(),
+      'checkboxes[foo]' => TRUE,
+      'select' => 'foo',
+      'radios' => 'bar',
+    );
+    $this->drupalPost('form-test/validate-required', $edit, t('Submit'));
+    $this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, t('No error message is displayed when all required fields are filled.'));
+    $this->assertRaw(t("The form_test_validate_required_form form was submitted successfully."), t('Validation form submitted successfully.'));
+  }
+
+  /**
    * Test default value handling for checkboxes.
    *
    * @see _form_test_checkbox()
diff --git a/core/modules/simpletest/tests/form_test.module b/core/modules/simpletest/tests/form_test.module
index 5e3fb17..d7df9e3 100644
--- a/core/modules/simpletest/tests/form_test.module
+++ b/core/modules/simpletest/tests/form_test.module
@@ -23,6 +23,13 @@ function form_test_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
+  $items['form-test/validate-required'] = array(
+    'title' => 'Form #required validation',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('form_test_validate_required_form'),
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
   $items['form-test/limit-validation-errors'] = array(
     'title' => 'Form validation with some error suppression',
     'page callback' => 'drupal_get_form',
@@ -346,6 +353,53 @@ function form_test_validate_form_validate(&$form, &$form_state) {
 }
 
 /**
+ * Form constructor for a form to test the #required property.
+ */
+function form_test_validate_required_form($form, &$form_state) {
+  $form['textfield'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Textfield'),
+    '#required' => TRUE,
+  );
+  $form['checkboxes'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Checkboxes'),
+    '#options' => drupal_map_assoc(array('foo', 'bar')),
+    '#required' => TRUE,
+  );
+  $form['select'] = array(
+    '#type' => 'select',
+    '#title' => t('Select'),
+    '#options' => drupal_map_assoc(array('foo', 'bar')),
+    '#required' => TRUE,
+  );
+  $form['radios'] = array(
+    '#type' => 'radios',
+    '#title' => t('Radios'),
+    '#options' => drupal_map_assoc(array('foo', 'bar')),
+    '#required' => TRUE,
+  );
+  $form['radios_optional'] = array(
+    '#type' => 'radios',
+    '#title' => t('Radios (optional)'),
+    '#options' => drupal_map_assoc(array('foo', 'bar')),
+  );
+  $form['actions'] = array('#type' => 'actions');
+  $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
+  return $form;
+}
+
+/**
+ * Form submit handler to test for proper submission.
+ *
+ * This message is checked for in the tests to confirm that this for
+ * successfully submitted without any errors.
+ */
+function form_test_validate_required_form_submit($form, &$form_state) {
+  drupal_set_message(t("The form_test_validate_required_form form was submitted successfully."));
+}
+
+/**
  * Builds a simple form with a button triggering partial validation.
  */
 function form_test_limit_validation_errors_form($form, &$form_state) {
