Spinning this new issue off from https://www.drupal.org/node/2656246 which has been already closed.

For starters : congrats with the entity reference views enhancement, making sitebuilder's lifes easier to cope with common business requirements.

For my current assignment, i was looking to use the latest dev branch for the following use case :
1. content type job_event, holding a multiple occurrences text field, named workshops.
2. same content type, holding an entity reference to a subscription webform
3. job_event node display (eg. /node/3347) embeds the webform
4. A webform component "Preferred workshops" allows subscribers to select 1 or more workshops, in checkbox modus.
5. This component is configured to use a custom entityreference view (see screenshot 1 with 5 results)
6. This view is using a contextual filter on content:nid, by configuration provided in the webform component settings as [current-page:url:unaliased:args:value:1]

The result of this setup only shows the last of 5 present workshops (see screenshot-2)

Digging into this module's code, i found out that the narrowing is somehow caused by $view->display_handler->set_option('entityreference_options', $entityreference_options); inside :

function webform_references_execute_view() {
  ...
 $view->set_display($display_name);
  // Make sure the query is not cached.
  $view->is_cacheable = FALSE;
  // Set the options for the display handler.
  $entityreference_options = array(
    'match' => $match,
    'match_operator' => $match_operator,
    'limit' => $limit,
    'ids' => $ids,
  );
  $view->display_handler->set_option('entityreference_options', $entityreference_options);
  $result = $view->execute_display($display_name, $args); 
  return $result;
  ...
}

Leaving this dispay_handler setting out does return the five workshop elements, but not in the expected array format (see screenshot 3).

I have no experience in using entityreference_options in code for display handling, so i could appreciate some assistance in making this use case to work.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RAWDESK created an issue. See original summary.

RAWDESK’s picture

Title: Webform entity reference node view : multiple occurrence within 1 node » Webform entity reference node view : multiple occurrences within 1 node
RAWDESK’s picture

Had another quick look at it today, but couldn't figure out the API of the entity_references display handler option.

So having my doubts if executing the display, returning rendered entities, is the right approach for populating this webform_references result.

Maybe the views_get_view_result() function, returning native views result objects, could bring a more flexible solution.
It also returns rendered markup that can be used for populating the result.
See screenshot-4 illustrating the result and target markup to be used.

Any shared thoughts ?
Thanks upfront

RAWDESK’s picture

#UPDATE

Because of business priorities and deadline, i moved to a less efficient content management solution :

- Create a new content type, in our case a "workshop" entity, linked as a reference to our "job_event" entity.
- New content type only holds title and body fields (standard drupal)
- Create new entity reference source view on this new content type :
ER view
(notice the additional Referencing Entity relationship i had to set up to get this end to linked to my job_event content type where the webform is exposed as rendered entity)
- In our webform component ER setting, i switched to this new entity reference source view .

This is the raw unstyled result :

example

By this i am also confirming this new "views feeded list" feature is working properly, although i our case it was a bit overkill to create a new content type just for managing the option titles...

RAWDESK’s picture

Category: Bug report » Feature request