If I have a multiple field and want to add an item at first position with a dynamic value, let's say depending on a term reference field that is also on the entity. But I don't want to save that value in the db to avoid syncing if the field, the logic depends, on changes. So I want to do that during the rendering process.

Where and how would I do that?

In preprocess hooks are multiple places that store infomration about the item:

  • $variables['element'][0]
  • $variables['element']['#items']
  • $variables['items'][0]
  • In the node or field template file.
    – No Sssweat
    Jul 21 at 2:34


Your Answer

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

Browse other questions tagged or ask your own question.