I have a set of values that are created in a different node, and I would like to use them as the allowed values for a field in another node. So, I have a view that collect the values and I have a hook_allowed_values function to create the allowed_values list. My function is:
function hnbuilder_fheq_allowed_values(FieldStorageConfig $ definition, ContentEntityInterface $ entity = NULL, $ cacheable){ $ node = \Drupal::routeMatch()->getParameter('node'); if ($ node instanceof \Drupal\node\NodeInterface) { $ nid = $ node->id(); } $ view_id = 'default'; $ args = $ nid; $ result = views_get_view_result('outcomes',$ view_id,$ args); return $ result; }
My problem is that my views_get_view_result
is not returning anything. I get the correct $ nid
, and pass this to the views...result
. The view, on its own, works fine. But if kint($ result)
, I get nothing.
I’ve updated the config for the field, to make it call the hook_allowed_values function.
What am I doing wrong?