I'm trying to populate a select list dynamically by pulling its values from a taxonomy term field linked to the current-user account. Just to clarify, below function is a hook defined by a module that came with a custom installation profile. It is basically used to create fields on a specific form. So, my custom module has-
function some_function_attributes() {
global $user;
$user_fields = user_load($user->uid);
$termid = $user_fields->field_user_organization['und']['0']['tid'];
$taxonomy_term = taxonomy_term_load($termid);
//dsm($taxonomy_term);
$options = field_get_items('taxonomy_term', $taxonomy_term, 'field_org_environment','select');
dsm($options);
return array(
'environment' => array(
'type' => 'select',
'options' => $options,
'name' => t('Environment'),
)
);
}
Allowed values in the field (for this user)-
E1|Env1
E2|Env2
Here's the devel screenshot for dsm($options);
So, its populating the right field but not in the way it should.
Actual form element looks like this-
Currently, its just returning the array and I can't figure out what I missed. Been banging my head to the wall for this- How would I populate Env1 and Env2 in this select-list ?