From a12ca2cd2a6a1ebcb510d511ed1b032ecc28e7a3 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Wed, 29 Feb 2012 12:00:48 -0800 Subject: [PATCH] Issue #1366854 by quicksketch: Added Pass #size attribute to the child upload field in the managed_file() element. --- core/modules/file/file.module | 3 ++- core/modules/file/tests/file.test | 4 ++++ core/modules/file/tests/file_module_test.module | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 078a24544285..2141cae59f13 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -72,6 +72,7 @@ function file_element_info() { '#progress_message' => NULL, '#upload_validators' => array(), '#upload_location' => NULL, + '#size' => 22, '#extended' => FALSE, '#attached' => array( 'css' => array($file_path . '/file.admin.css'), @@ -443,7 +444,7 @@ function file_managed_file_process($element, &$form_state, $form) { '#type' => 'file', '#title' => t('Choose a file'), '#title_display' => 'invisible', - '#size' => 22, + '#size' => $element['#size'], '#theme_wrappers' => array(), '#weight' => -10, ); diff --git a/core/modules/file/tests/file.test b/core/modules/file/tests/file.test index 538118a0f2a4..459609b08480 100644 --- a/core/modules/file/tests/file.test +++ b/core/modules/file/tests/file.test @@ -239,6 +239,10 @@ class FileManagedFileElementTestCase extends FileFieldTestCase { * Tests the managed_file element type. */ function testManagedFile() { + // Check that $element['#size'] is passed to the child upload element. + $this->drupalGet('file/test'); + $this->assertFieldByXpath('//input[@name="files[nested_file]" and @size="13"]', NULL, 'The custom #size attribute is passed to the child upload element.'); + // Perform the tests with all permutations of $form['#tree'] and // $element['#extended']. foreach (array(0, 1) as $tree) { diff --git a/core/modules/file/tests/file_module_test.module b/core/modules/file/tests/file_module_test.module index d75e929dc09f..490ef4299119 100644 --- a/core/modules/file/tests/file_module_test.module +++ b/core/modules/file/tests/file_module_test.module @@ -37,6 +37,7 @@ function file_module_test_form($form, &$form_state, $tree = TRUE, $extended = FA '#upload_location' => 'public://test', '#progress_message' => t('Please wait...'), '#extended' => (bool) $extended, + '#size' => 13, ); if ($default_fid) { $form['nested']['file']['#default_value'] = $extended ? array('fid' => $default_fid) : $default_fid; -- GitLab