On a Webform, without the "Select (or other)" module, one can change the default text on a required select list from "- Select" to custom text like so (see https://drupal.org/node/1331956):

function yourmodule_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
      
    case 'webform_client_form_your_webform_id':
            $form['submitted']['component_name']['#default_value'] = '';
            $form['submitted']['component_name']['#empty_value'] = '';
            $form['submitted']['component_name']['#empty_option'] = '- Select country -'; 

            break;
  }
}

This code does nothing when the "Select (or other)" module "Allow 'Other...' option" is used.

Comments

legolasbo’s picture

Issue summary: View changes
Status: Active » Fixed

Bug fixed, thanks for reporting it! :)

  • legolasbo committed aa4fae6 on 7.x-2.x
    Issue #2073375: hook_form_alter for empty_value not working
    

  • legolasbo committed aa4fae6 on 7.x-3.x
    Issue #2073375: hook_form_alter for empty_value not working
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.