Alter a Selection Field -None- Value

Public

If you want to change the value of the selection list in a node/user edit form that is optional

</> CopyGet raw version
php
  1. /*
  2.  * Implement hook_form_alter().
  3.  */
  4.  
  5. function {modulename}_form_alter(&$form, &$form_state, $form_id){
  6. // We are altering the select list empty value for {field_name} field in User Profile
  7. if($form_id == "user_profile_form"){
  8. $form['{field_name}']['und']['#empty_option'] = t('Something you want');
  9. $form['{field_name}']['und']['#empty_value'] = t('_none');
  10. }
  11. }