Hi

how to change allowed values of select list ?

Comments

karolio007’s picture

really big help for beginner

also You could write: look at google.com ;)

visabhishek’s picture

In My case i am using a custom code like :


function dynallowed_form_field_ui_field_settings_form_alter(&$form, &$form_state){
  dynallowed_form_field_ui_field_edit_form_alter($form, $form_state);
}
function dynallowed_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
  if (user_access('administer dynallowed')) {
    $form['field']['settings']['allowed_values_function'] = array(
      '#type' => 'select',
      '#title' => t('Allowed value function'),
      '#default_value' => $form['field']['settings']['allowed_values_function']['#value'],
      '#options' => dynallowed_allowed_functions_callbacks(),
      '#empty_value' => '',
      '#empty_option' => t('Allowed values list'),
    );
  }
}

function dynallowed_allowed_functions_callbacks() {
  $options = array(
    'allowed_values_function' => t('Dynamic Value From function'),
  );
  return $options;
}

function allowed_values_function(){
// Write Your Code Here
return array(
    'AF'=>'Afghanistan',
    'AL'=>'Albania',
    'DZ'=>'Algeria',
    'AS'=>'American Samoa',
    'AD'=>'Andorra',
    'AO'=>'Angola',
  );
}

Hope its helpful for you.. !!!