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.
Hi - I need to get the list of Allow Values in a Select or Other field. They're not showing up in field_info_fields();
Where's this data stored? How can I retrieve it?
thanks
Comments
Comment #1
haydeniv CreditAttribution: haydeniv commentedThe data is stored in the widget info not the field info. Accessing it depends on when you want to get the data. Is this is a form alter, or on the display side, or just informational?
Comment #2
steveixa CreditAttribution: steveixa commentedit's informational. I need to generate a report using those fields as an axis on a graph, i.e. graph of the number of nodes with each option selected.
Comment #3
haydeniv CreditAttribution: haydeniv commentedI think I'd just do a distinct sql query against your field in the field_data_field_your_field_name table.
Because it is stored in the widget settings you'd have to fake a form and then extract the widget values out but that would be a bit tricky I think. I'm pretty sure the actual data is stored in a blob in field_config_instance but that would be really messy to get at. The available options are distinct per field so you would need to try and discover each field that uses a select_or_other widget to pull it out.
Comment #4
steveixa CreditAttribution: steveixa commentedok - thanks @haydeniv. I'll give it a try.
Comment #5
Raphael Apard CreditAttribution: Raphael Apard commentedI was looking for a module like select_or_other but with a field with same functionalities as core "list_text" field, so i wrote a sandbox : https://www.drupal.org/sandbox/wdki/2365003
Comment #6
legolasbo