<?php
/**
* Implements hook_permission().
*/
function dynallowed_permission() {
return array(
'administer dynallowed' => array(
'title' => t('Alter Field List Allowed Values Function'),
'description' => t('This give field administrators access to alter the options list source for fields.'),
),
);
}
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',
'AD'=>'Andorra',
'AO'=>'Angola',
);
}