- Patch #623992 by sun: fixed the tests. We can re-enable the test bot now.
parent
a75f741e9b
commit
3213087441
|
@ -832,7 +832,10 @@ 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('!name field is required.', array('!name' => $elements['#title'])));
|
||||
form_error($elements, $t('<a href="#!field_id">!name</a> field is required.', array(
|
||||
'!field_id' => $elements['#id'],
|
||||
'!name' => $elements['#title'],
|
||||
)));
|
||||
}
|
||||
|
||||
// Verify that the value is not longer than #maxlength.
|
||||
|
@ -2762,14 +2765,21 @@ 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', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
|
||||
$output .= ' <label for="' . $element['#id'] . '">' . $t('!title !required !error', array('!title' => filter_xss_admin($title), '!required' => $required, '!error' => $error)) . "</label>\n";
|
||||
}
|
||||
else {
|
||||
$output .= ' <label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
|
||||
$output .= ' <label>' . $t('!title !required !error', array('!title' => filter_xss_admin($title), '!required' => $required, '!error' => $error)) . "</label>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function module_list($refresh = FALSE, $bootstrap = FALSE, $sort = FALSE, $fixed
|
|||
$list = system_list('bootstrap');
|
||||
}
|
||||
else {
|
||||
$list = system_list('module');
|
||||
$list = system_list('module_enabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,31 +101,47 @@ function system_list($type) {
|
|||
$lists = &drupal_static(__FUNCTION__);
|
||||
|
||||
if (!isset($lists)) {
|
||||
$lists = array('bootstrap' => array(), 'module' => array(), 'theme' => array());
|
||||
$lists = array(
|
||||
'bootstrap' => array(),
|
||||
'module' => array(),
|
||||
'module_enabled' => array(),
|
||||
'theme' => array(),
|
||||
'theme_enabled' => array(),
|
||||
);
|
||||
// The module name (rather than the filename) is used as the fallback
|
||||
// weighting in order to guarantee consistent behavior across different
|
||||
// Drupal installations, which might have modules installed in different
|
||||
// locations in the file system. The ordering here must also be
|
||||
// consistent with the one used in module_implements().
|
||||
$result = db_query("SELECT * FROM {system} WHERE status = 1 ORDER BY weight ASC, name ASC");
|
||||
$result = db_query("SELECT * FROM {system} ORDER BY weight ASC, name ASC");
|
||||
foreach ($result as $record) {
|
||||
// Build a list of all enabled modules.
|
||||
// Build a list of all modules.
|
||||
if ($record->type == 'module') {
|
||||
$lists['module'][$record->name] = $record->name;
|
||||
// Build a separate array of modules required for bootstrap.
|
||||
if ($record->bootstrap) {
|
||||
$lists['bootstrap'][$record->name] = $record->name;
|
||||
// Build a list of all enabled modules.
|
||||
if ($record->status) {
|
||||
$lists['module_enabled'][$record->name] = $record->name;
|
||||
// Build a separate array of modules required for bootstrap.
|
||||
if ($record->bootstrap) {
|
||||
$lists['bootstrap'][$record->name] = $record->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build a list of enabled themes.
|
||||
// Build a list of themes.
|
||||
if ($record->type == 'theme') {
|
||||
$lists['theme'][$record->name] = $record;
|
||||
// Build a list of enabled themes.
|
||||
if ($record->status) {
|
||||
$lists['theme_enabled'][$record->name] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
// Additionally prime drupal_get_filename() with the filename and type
|
||||
// for each record, this prevents subsequent database lookups when
|
||||
// drupal_get_filename() is called without the 'file' argument.
|
||||
drupal_get_filename($record->type, $record->name, $record->filename);
|
||||
if ($record->status) {
|
||||
drupal_get_filename($record->type, $record->name, $record->filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
|
||||
$this->assertText(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->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation');
|
||||
$this->assertText(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) {
|
||||
|
|
|
@ -1567,7 +1567,7 @@ function system_schema() {
|
|||
),
|
||||
'primary key' => array('filename'),
|
||||
'indexes' => array(
|
||||
'system_list' => array('status', 'weight', 'name'),
|
||||
'system_list' => array('weight', 'name'),
|
||||
'type_name' => array('type', 'name'),
|
||||
),
|
||||
);
|
||||
|
@ -2203,7 +2203,7 @@ function system_update_7018() {
|
|||
db_drop_index('system', 'bootstrap');
|
||||
db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
|
||||
db_add_index('system', 'type_name', array('type', 'name'));
|
||||
db_add_index('system', 'system_list', array('status', 'weight', 'name'));
|
||||
db_add_index('system', 'system_list', array('weight', 'name'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue