Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By BijanZ on
How can I get all options for a fields?
For example, There is a field with 3 options in allowed values, like option1, option2, option3.Is there any function which receive the field name and returns selected values not a keys ?
With this just return key of selected opinion
print ($node->field_opinion['und'][0]['value'])
Comments
You can run foreach loop and
You can run foreach loop and get desired result.