Commit e88a2178 authored by Dries's avatar Dries
Browse files

- Rollback of #447816.

parent 2387e71f
......@@ -832,10 +832,7 @@ function _form_validate($elements, &$form_state, $form_id = NULL) {
// checkboxes, can return a valid value of '0'. Instead, check the
// length if it's a string, and the item count if it's an array.
if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
form_error($elements, $t('<a href="#!field_id">!name</a> field is required.', array(
'!field_id' => $elements['#id'],
'!name' => $elements['#title'],
)));
form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
}
// Verify that the value is not longer than #maxlength.
......@@ -2770,21 +2767,14 @@ function theme_form_element($variables) {
$output = '<div class="' . implode(' ', $class) . '">' . "\n";
$required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
$error = '';
if (!empty($element['#required']) && empty($element['#value'])) {
$error = form_get_error($element) ? '<span class="error">' . $t('Field is required.') . '</span>' : '';
}
else {
$error = form_get_error($element) ? '<span class="error">' . filter_xss_admin(form_get_error($element)) . '</span>' : '';
}
if (!empty($element['#title']) && empty($element['#form_element_skip_title'])) {
$title = $element['#title'];
if (!empty($element['#id'])) {
$output .= ' <label for="' . $element['#id'] . '">' . $t('!title !required !error', array('!title' => filter_xss_admin($title), '!required' => $required, '!error' => $error)) . "</label>\n";
$output .= ' <label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
}
else {
$output .= ' <label>' . $t('!title !required !error', array('!title' => filter_xss_admin($title), '!required' => $required, '!error' => $error)) . "</label>\n";
$output .= ' <label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
}
}
......
......@@ -1432,7 +1432,7 @@ class FieldFormTestCase extends FieldTestCase {
// Submit with missing required value.
$edit = array();
$this->drupalPost('test-entity/add/test-bundle', $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
$this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
// Create an entity
$value = mt_rand(1, 127);
......@@ -1448,7 +1448,7 @@ class FieldFormTestCase extends FieldTestCase {
$value = '';
$edit = array("{$this->field_name}[$langcode][0][value]" => $value);
$this->drupalPost('test-entity/' . $id . '/edit', $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
$this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
}
// function testFieldFormMultiple() {
......
......@@ -52,7 +52,7 @@ class FormsTestCase extends DrupalWebTestCase {
$elements['file']['empty_values'] = $empty_strings;
// Regular expression to find the expected marker on required elements.
$required_marker_preg = '@<label.*<span class="form-required" title="This field is required\.">\*</span>.*</label>@';
$required_marker_preg = '@<label.*<span class="form-required" title="This field is required\.">\*</span></label>@';
// Go through all the elements and all the empty values for them
foreach ($elements as $type => $data) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment