### Eclipse Workspace Patch 1.0 #P Drupal-7-Dev Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.304 diff -u -r1.304 form.inc --- includes/form.inc 15 Nov 2008 15:32:36 -0000 1.304 +++ includes/form.inc 16 Nov 2008 01:15:50 -0000 @@ -852,7 +852,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; @@ -865,6 +865,7 @@ if (isset($form['#type']) && $form['#type'] == 'form') { $cache = NULL; + $enctype = NULL; $complete_form = $form; if (!empty($form['#programmed'])) { $form_state['submitted'] = TRUE; @@ -943,19 +944,21 @@ if (!empty($form['#cache'])) { $cache = $form['#cache']; } - // If there is a file element, we need to flip a static flag so later the - // form encoding can be set. - if (isset($form['#type']) && $form['#type'] == 'file') { - $file = TRUE; + // 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 (isset($form['#type']) && $form['#type'] == 'form') { // 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'; + // Set the form encoding if required. + if (isset($enctype)) { + $form['#attributes']['enctype'] = $enctype; } } return $form;