I use this field in profile2 profile. When I set it as "required" the default value is "- Select -". When I set it to not required, the default value becomes "- Select a value -". I am not sure if this is correct behavior. On the normal select widget the default value in both cases is "- Select a value -".

Comments

legolasbo’s picture

Status: Active » Closed (duplicate)
Related issues: +#1895154: Sort "Other" to top of list

This issue is a duplicate of #1895154: Sort "Other" to top of list

Channel Islander’s picture

Status: Closed (duplicate) » Active

Both this and its duplicate were closed as duplicates! (And this is not really a duplicate of the other issue, anyway).

Reopening because the OP's question has not been answered.

legolasbo’s picture

I accidentally closed it agains the wrong issue, but it is a duplicate. #1830090: Align with Drupal core select list, NULL (-None-) value. has a patch for review which aligns the options with Drupal core.

You are correct that the drupal list module uses - Select a value -, but Drupal core uses - Select - and I think It's a pretty sensible default.

code below is from form.inc

    // If the element is required and there is no #default_value, then add an
    // empty option that will fail validation, so that the user is required to
    // make a choice. Also, if there's a value for #empty_value or
    // #empty_option, then add an option that represents emptiness.
    if (($required && !isset($element['#default_value'])) || isset($element['#empty_value']) || isset($element['#empty_option'])) {
      $element += array(
        '#empty_value' => '',
        '#empty_option' => $required ? t('- Select -') : t('- None -'),
Channel Islander’s picture

Thanks!