### Eclipse Workspace Patch 1.0 #P Drupal-7-Dev Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.642 diff -u -r1.642 system.module --- modules/system/system.module 22 Nov 2008 13:55:27 -0000 1.642 +++ modules/system/system.module 23 Nov 2008 03:54:45 -0000 @@ -341,6 +341,7 @@ $type['file'] = array( '#input' => TRUE, '#size' => 60, + '#enctype' => 'multipart/form-data', ); Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.105 diff -u -r1.105 system.admin.inc --- modules/system/system.admin.inc 20 Nov 2008 06:56:17 -0000 1.105 +++ modules/system/system.admin.inc 23 Nov 2008 03:54:43 -0000 @@ -517,7 +517,6 @@ } } } - $form['#attributes'] = array('enctype' => 'multipart/form-data'); $form = system_settings_form($form); // We don't want to call system_settings_form_submit(), so change #submit. Index: modules/user/user.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v retrieving revision 1.22 diff -u -r1.22 user.pages.inc --- modules/user/user.pages.inc 13 Oct 2008 00:33:05 -0000 1.22 +++ modules/user/user.pages.inc 23 Nov 2008 03:54:46 -0000 @@ -246,7 +246,6 @@ '#submit' => array('user_edit_delete_submit'), ); } - $form['#attributes']['enctype'] = 'multipart/form-data'; return $form; } Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.305 diff -u -r1.305 form.inc --- includes/form.inc 22 Nov 2008 13:03:06 -0000 1.305 +++ includes/form.inc 23 Nov 2008 03:54:41 -0000 @@ -851,7 +851,7 @@ * $_POST data. */ function form_builder($form_id, $form, &$form_state) { - static $complete_form, $cache, $file; + static $complete_form, $cache, $enctype; // Initialize as unprocessed. $form['#processed'] = FALSE; @@ -864,6 +864,7 @@ if (isset($form['#type']) && $form['#type'] == 'form') { $cache = NULL; + $enctype = NULL; $complete_form = $form; if (!empty($form['#programmed'])) { $form_state['submitted'] = TRUE; @@ -937,6 +938,12 @@ unset($form_state['buttons']); } + // If an element requires to set the forms content type enctype attribute, we + // need to store this info in a static $enctype flag to update the parent + // form element. E.g. For files, non-ASCII data, and binary data. + if (isset($form['#enctype'])) { + $enctype = $form['#enctype']; + } // If some callback set #cache, we need to flip a static flag so later it // can be found. if (!empty($form['#cache'])) { @@ -948,14 +955,15 @@ $file = TRUE; } if (isset($form['#type']) && $form['#type'] == 'form') { + // Set the form encoding if required. + if (isset($enctype)) { + $form['#attributes']['enctype'] = $enctype; + } + // We are on the top form, we can copy back #cache if it's set. if (isset($cache)) { $form['#cache'] = TRUE; } - // If there is a file element, we set the form encoding. - if (isset($file)) { - $form['#attributes']['enctype'] = 'multipart/form-data'; - } } return $form; } Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.215 diff -u -r1.215 upload.module --- modules/upload/upload.module 8 Nov 2008 21:35:10 -0000 1.215 +++ modules/upload/upload.module 23 Nov 2008 03:54:45 -0000 @@ -258,7 +258,6 @@ } else { $form['attachments']['wrapper'] += _upload_form($node); - $form['#attributes']['enctype'] = 'multipart/form-data'; } } $form['#submit'][] = 'upload_node_form_submit';