In Drupal 6, by default, a required CCK field will display the first allowed value.
I want it displays "- Please Select -": Is there an easy way to do this?

I do not want to save "- Please Select -" in the database.

link|improve this question

feedback

4 Answers

up vote 6 down vote accepted

Use the key|label format for allowed values:

|-Please Select -
1|option1
2|option2
3|option3

By making the key for "-Please Select -" an empty string, the form can't be submitted with this value.

link|improve this answer
This should work if the field is required. – googletorp Aug 12 '11 at 21:29
This worked amazingly! – iStryker Aug 12 '11 at 23:07
feedback

In the list of options of global settings of field you can put in first place the option - Please Select - :

-Please Select -
option1
option2
option3

Save the field.

After in the field settings you choose - Please Select - in default value of the field.

Finally you save the configuration of field.

link|improve this answer
I thought of this, however I do not want - Please Select - be saved to the database – iStryker Aug 12 '11 at 20:11
feedback

Put your field as not required and then in a hook_nodeapi() check that the user has effectively selected a value:

function custom_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'validate') {
      if ($node->field_select[0]['value'] == '') {
        form_set_error('field_select', t('Please select a value.'));
      }
  }
}
link|improve this answer
feedback

seems like AHAH can do the job to populate select list or add items: AHAH - populating a select (list) with a select (drop-down).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.