0

Can you get allowed values for reference field?

i tried with:

$all_fields_info = field_info_fields();
$allowed_values= list_allowed_values($all_fields_info["field_user_ref"]);

but it is not working ..

2
  • An entity reference field isn't an list field, so no, it doesn't haves "allowed values" as such
    – Clive
    Aug 14, 2013 at 11:39
  • How do you get the available options then?
    – gregab
    Aug 15, 2013 at 5:56

1 Answer 1

1

For an entityreference fields use:

$allowed_values = entityreference_get_selection_handler("field_user_ref")->getReferencableEntities();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.