Problems rendering render array that's a child of another render array.

Events happening in the community are now at Drupal community events on www.drupal.org.
RobW's picture

Right now I'm re-writing the theme implementation for the Field Collection module. Totally stuck on rendering a very simple render array as a child of the field collection field -- it attaches fine and renders everywhere else I stick it, no problem. But it won't render there.

I have a suspicion it has something to do with theme_field, which the parent render array is rendered by. Tested my array as a child in an array rendered by theme_entity, and that worked fine.

Patch and more info at http://drupal.org/node/1157794#comment-6257474. Any ideas?

Comments

I just gave it a quick look,

linclark's picture

I just gave it a quick look, so can't say for sure... but sometimes wrapping that kind of stuff in another array, keyed by 'children', works.

You can see an example of this in my GSOC student's patch for Birthdays module, http://drupal.org/node/1438612.

Thanks for taking a look Lin,

RobW's picture

Thanks for taking a look Lin, I'll give it a try. I thought I read that drupal render writes the markup for all child rendered arrays to #children. I considered that earlier but was afraid to overwrite/ take a maybe-hacky way out.

I'm pretty sure I need to either preprocess or extend theme_field, if I wanted to do things the "right" way. But hey, anything that works, works.

I'm not sure whether using

linclark's picture

I'm not sure whether using children is considered hacky or not. sun actually suggested using 'children' for theme_datetime in Drupal 8, http://drupal.org/files/drupal8.datetime.196.patch. For the record, I actually opposed him on that ;)

It turned out that the method

RobW's picture

It turned out that the method I was using wasn't getting into the render array early enough for field to do anything with it, and was probably a horrible way to do it anyways. All for the best -- I ended up using a much simpler/better method to add the content I needed.

If anyone wants to see the results, the ready for review patch to Field Collection is here: http://drupal.org/node/1157794#comment-6311148.

Pittsburgh

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: