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.
Trying to render an entity with a list property throws warnings, as entity_property_default_render_value_by_type()
passes the output of $property->value()
directly to check_plain().
Comment | File | Size | Author |
---|---|---|---|
#2 | 2237141-2-entity-render-property-list.patch | 993 bytes | mr.baileys |
#1 | 2237141.1-list-warning.patch | 897 bytes | deviantintegral |
Comments
Comment #1
deviantintegral CreditAttribution: deviantintegral commentedComment #2
mr.baileysRan into the same problem and arrived here while searching for before creating a new bug in the issue queue.
The patch in #1 seems ok, although very basic: for example, a "list" would probably render "1,0,1" instead of "Yes,No,Yes". We are currently running with the attached patch.
Comment #3
claudiu.cristeaThe patch from #2 is making the following assumptions:
<ul>
item list.So the patch is only for a specific case., not ready to go in.
Comment #4
claudiu.cristeaThe described problems are having the cause in the bug from #2109825: theme_entity_property() doesn't respect 'content' variable. If you apply that patch, then you can build the content for a specific element in
hook_entity_view()
orEntityAPIControllerInterface::buildContent()
by adding the#content
to the element with the rendered value.In your case, you'll need to implement
hook_entity_view()
and there:theme('item_list, ...)
$entity->content['your_property']['#content']
While this issue cannot provide a generic solution but only "case specific" solutions like #1 and #2, I'm closing this as "won't fix".
Comment #5
apotek CreditAttribution: apotek commentedThese patches no longer apply due to entity module updates.