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().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deviantintegral’s picture

Status: Active » Needs review
FileSize
897 bytes
mr.baileys’s picture

Ran 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.

claudiu.cristea’s picture

Status: Needs review » Needs work

The patch from #2 is making the following assumptions:

  1. A item in the list is always a text or boolean.
  2. The list is always displayed as <ul> item list.

So the patch is only for a specific case., not ready to go in.

claudiu.cristea’s picture

Status: Needs work » Closed (won't fix)
Related issues: +#2109825: theme_entity_property() doesn't respect 'content' variable

The 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() or EntityAPIControllerInterface::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:

  1. Build the list with theme('item_list, ...)
  2. Store the result in $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".

apotek’s picture

These patches no longer apply due to entity module updates.