Drupal - How to programmatically update the allowed values of a list field?
Something along the lines of...
// Get the field info
$info = field_info_field('field_some_field');
// Get a reference to the values
$values = &$info['settings']['allowed_values'];
// Manipulate the values in some way, e.g.
$values['new_value'] = 'New Value';
// Save the field
field_update_field($info);
You'd better use the allowed_values_function
with a callback:
'settings' => array(
'allowed_values' => array(),
'allowed_values_function' => '_my_feature_module_options_list',
),
See Creating dynamic allowed values options for an entity field.