1

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.

7

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.

  • 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
0

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.

  • I thought of this, however I do not want - Please Select - be saved to the database – iStryker Aug 12 '11 at 20:11
0

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.'));
      }
  }
}
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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