Index: modules/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile.module,v
retrieving revision 1.90.2.3
diff -u -r1.90.2.3 profile.module
--- modules/profile.module	24 Nov 2005 21:18:48 -0000	1.90.2.3
+++ modules/profile.module	9 Jan 2006 15:27:23 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: profile.module,v 1.90.2.3 2005/11/24 21:18:48 unconed Exp $
+// $Id: profile.module,v 1.90.2.3 2005-11-24 21:18:48 unconed Exp $
 
 /**
  * @file
@@ -279,7 +279,9 @@
         $fields[$category] .= form_checkbox(check_plain($field->title), $field->name, 1, $edit[$field->name], _profile_form_explanation($field), NULL, $field->required);
         break;
       case 'selection':
-        $options = array('--');
+        if (!$field->required) {
+          $options = array('--');
+        }
         $lines = split("[,\n\r]", $field->options);
         foreach ($lines as $line) {
           if ($line = trim($line)) {
@@ -430,6 +432,11 @@
   if (!$edit['category']) {
     form_set_error('category', t('You must enter a category.'));
   }
+
+  // Validation for a 'selection' field
+  if (($edit['type'] == 'selection') && $edit['required'] && !$edit['options']) {
+    form_set_error('options', t('You must enter selection options.'));
+  }
 }
 
 /**
@@ -509,7 +516,8 @@
 
 function _profile_field_form($type, $edit = array()) {
 
-  $group  = form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t('The category the new field should be part of.  Categories are used to group fields logically.  An example category is "Personal information".'));
+  $group  = form_hidden('type', $type);
+  $group .= form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t('The category the new field should be part of.  Categories are used to group fields logically.  An example category is "Personal information".'));
   $group .= form_textfield(t('Title'), 'title', $edit['title'], 70, 128, t('The title of the new field.  The title will be shown to the user.  An example title is "Favorite color".'));
   $group .= form_textfield(t('Form name'), 'name', $edit['name'], 70, 128, t('The name of the field.  The form name is not shown to the user but used internally in the HTML code and URLs.
 Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields.  Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'));
