Issue #1734716 by larowlan: Fixed File field form label has incorrect id in @for attribute.

8.0.x
catch 2012-08-29 11:17:27 +01:00
parent 27b89c3fd0
commit 3400bc2cb5
2 changed files with 6 additions and 0 deletions

View File

@ -370,6 +370,9 @@ function file_file_predelete(File $file) {
* This function is assigned as a #process callback in file_element_info().
*/
function file_managed_file_process($element, &$form_state, $form) {
// Append the '-upload' to the #id so the field label's 'for' attribute
// corresponds with the file element.
$element['#id'] .= '-upload';
$fid = isset($element['#value']['fid']) ? $element['#value']['fid'] : 0;
// Set some default element properties.

View File

@ -68,6 +68,9 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure the page now has an upload button instead of a remove button.
$this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.'));
$this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.'));
// Test label has correct 'for' attribute.
$label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . LANGUAGE_NOT_SPECIFIED . "-0-upload']");
$this->assertTrue(isset($label[0]), 'Label for upload found.');
// Save the node and ensure it does not have the file.
$this->drupalPost(NULL, array(), t('Save'));