summaryrefslogtreecommitdiff
path: root/modules/file
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:54:36 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:54:36 -0800
commitc8d1e91a860204451d9ce87f4509c2182a337699 (patch)
treeaae1dc7d23d29952713337c2512a4c8cd72c1db0 /modules/file
parenta11889c035b4e7b10af70caf2cba9fcc9201f9e1 (diff)
downloadbrdo-c8d1e91a860204451d9ce87f4509c2182a337699.tar.gz
brdo-c8d1e91a860204451d9ce87f4509c2182a337699.tar.bz2
Issue #1366854 by quicksketch: Added Pass #size attribute to the child upload field in the managed_file() element.
Diffstat (limited to 'modules/file')
-rw-r--r--modules/file/file.module3
-rw-r--r--modules/file/tests/file.test4
-rw-r--r--modules/file/tests/file_module_test.module1
3 files changed, 7 insertions, 1 deletions
diff --git a/modules/file/file.module b/modules/file/file.module
index 506b0e91d..ebf80e9f3 100644
--- a/modules/file/file.module
+++ b/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.css'),
@@ -442,7 +443,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/modules/file/tests/file.test b/modules/file/tests/file.test
index 1b5fdf5cd..7fa6d6f01 100644
--- a/modules/file/tests/file.test
+++ b/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/modules/file/tests/file_module_test.module b/modules/file/tests/file_module_test.module
index 358c8b011..f66c749dd 100644
--- a/modules/file/tests/file_module_test.module
+++ b/modules/file/tests/file_module_test.module
@@ -36,6 +36,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;