Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.93
diff -u -r1.93 form.inc
--- includes/form.inc	7 Apr 2006 13:22:12 -0000	1.93
+++ includes/form.inc	8 Apr 2006 14:09:33 -0000
@@ -476,6 +476,7 @@
 
   /* Call the form element renderer */
   if (!isset($elements['#printed'])) {
+    _form_set_class($elements);
     $content = theme(($elements['#type']) ? $elements['#type']: 'markup', $elements);
     $elements['#printed'] = TRUE;
   }
@@ -512,6 +513,7 @@
     '#tree' => FALSE,
     '#parents' => array()
   );
+
   if (!isset($cache) || $refresh) {
     $cache = array();
     foreach (module_implements('elements') as $module) {
@@ -565,7 +567,6 @@
 function theme_select($element) {
   $select = '';
   $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
-  _form_set_class($element, array('form-select'));
   return theme('form_element', $element['#title'], '<select name="'. $element['#name'] .''. ($element['#multiple'] ? '[]' : '') .'"'. ($element['#multiple'] ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="' . $element['#id'] .'" '. $size .'>'. form_select_options($element) .'</select>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
 }
 
@@ -631,7 +632,6 @@
  *   A themed HTML string representing the form item group.
  */
 function theme_radio($element) {
-  _form_set_class($element, array('form-radio'));
   $output = '<input type="radio" ';
   $output .= 'name="' . $element['#name'] .'" ';
   $output .= 'value="'. $element['#return_value'] .'" ';
@@ -826,7 +826,6 @@
  *   A themed HTML string representing the checkbox.
  */
 function theme_checkbox($element) {
-  _form_set_class($element, array('form-checkbox'));
   $checkbox = '<input ';
   $checkbox .= 'type="checkbox" ';
   $checkbox .= 'name="'. $element['#name'] .'" ';
@@ -915,14 +914,12 @@
  */
 function theme_textfield($element) {
   $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
-  $class = array('form-text');
   $extra = '';
   if ($element['#autocomplete_path']) {
     drupal_add_js('misc/autocomplete.js');
-    $class[] = 'form-autocomplete';
+    $element['#attributes']['class'] .= ' form-autocomplete';
     $extra =  '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />';
   }
-  _form_set_class($element, $class);
   $output = '<input type="text" maxlength="'. $element['#maxlength'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />';
   return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)). $extra;
 }
@@ -952,14 +949,13 @@
  *   A themed HTML string representing the textarea.
  */
 function theme_textarea($element) {
-  $class = array('form-textarea');
   if ($element['#resizable'] !== false) {
     drupal_add_js('misc/textarea.js');
-    $class[] = 'resizable';
+    $element['#attributes']['class'] .= ' resizable';
   }
 
   $cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : '';
-  _form_set_class($element, $class);
+
   return theme('form_element', $element['#title'], '<textarea'. $cols .' rows="'. $element['#rows'] .'" name="'. $element['#name'] .'" id="' . $element['#id'] .'" '. drupal_attributes($element['#attributes']) .'>'. check_plain($element['#value']) .'</textarea>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
 }
 
@@ -991,7 +987,6 @@
 function theme_password($element) {
   $size = $element['#size'] ? ' size="'. $element['#size'] .'" ' : '';
 
-  _form_set_class($element, array('form-text'));
   $output = '<input type="password" maxlength="'. $element['#maxlength'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size . drupal_attributes($element['#attributes']) .' />';
 
   return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
@@ -1036,7 +1031,6 @@
  * provided by file.inc.
  */
 function theme_file($element) {
-  _form_set_class($element, array('form-file'));
   return theme('form_element', $element['#title'], '<input type="file" name="'. $element['#name'] .'"'. ($element['#attributes'] ? ' '. drupal_attributes($element['#attributes']) : '') .' id="'. form_clean_id($element['#id']) .'" size="'. $element['#size'] ."\" />\n", $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
 }
 
@@ -1047,20 +1041,14 @@
  *
  * @param &$element
  *   The form element
- * @param $name
- *   Array of new class names to be added
  */
-function _form_set_class(&$element, $class = array()) {
+function _form_set_class(&$element) {
   if ($element['#required']) {
-    $class[] = 'required';
+    $element['#attributes']['class'] .= ' required';
   }
   if (form_get_error($element)){
-    $class[] = 'error';
-  }
-  if (isset($element['#attributes']['class'])) {
-    $class[] = $element['#attributes']['class'];
+    $element['#attributes']['class'] .= ' error';
   }
-  $element['#attributes']['class'] = implode(' ', $class);
 }
 
 /**
Index: modules/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system.module,v
retrieving revision 1.308
diff -u -r1.308 system.module
--- modules/system.module	6 Apr 2006 18:07:22 -0000	1.308
+++ modules/system.module	8 Apr 2006 16:01:19 -0000
@@ -58,25 +58,25 @@
   $type['form'] = array('#method' => 'post', '#action' => request_uri());
 
   // Inputs
-  $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
+  $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1, '#attributes' => array('class' => 'form-checkbox'));
   $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#form_submitted' => TRUE);
   $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#form_submitted' => FALSE);
-  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
-  $type['password'] = array('#input' => TRUE, '#size' => 30);
+  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#attributes' => array('class' => 'form-text'));
+  $type['password'] = array('#input' => TRUE, '#size' => 30, '#attributes' => array('class' => 'form-text'));
   $type['password_confirm'] = array('#input' => TRUE,
     '#value' => 'pass',
     'pass1' => array('#type' => 'password', '#size' => 12),
     'pass2' => array('#type' => 'password', '#size' => 12),
     '#validate' => array('password_confirm_validate' => array()),
   );
-  $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5);
+  $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#attributes' => array('class' => 'form-textarea'));
   $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios' => array()));
-  $type['radio'] = array('#input' => TRUE);
+  $type['radio'] = array('#input' => TRUE, '#attributes' => array('class' => 'form-radio'));
   $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE);
-  $type['select'] = array('#input' => TRUE);
+  $type['select'] = array('#input' => TRUE, '#attributes' => array('class' => 'form-select'));
   $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0);
   $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()));
-  $type['file'] = array('#input' => TRUE, '#size' => 60);
+  $type['file'] = array('#input' => TRUE, '#size' => 60, '#attributes' => array('class' => 'form-file'));
 
   // Form structure
   $type['item'] = array();
