0

I have the following code:

$form['commerce_fieldgroup_pane__group_event_information']['field_event_information']['und'][0]['#markup'] = drupal_render(node_view($eventInfo['event']), 'teaser');

and for some reason, its printing out the node fine, but not printing the correct view mode, its always using full.

4

I think you have a misplace parenthesis. You have

$form[...] = drupal_render(node_view($eventInfo['event']), 'teaser');

The view mode should be a parameter to node_view() and not drupal_render():

$form[...] = drupal_render(node_view($eventInfo['event'], 'teaser'));

As a side note, I don't think you need to explicity render the node and stuff it into a #markup. node_view() returns a render array with a #theme already defined, so you should be able to do:

$form['commerce_fieldgroup_pane__group_event_information']['field_event_information'][LANGUAGE_NONE][0] = node_view($eventInfo['event'], 'teaser');

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.