Closed (fixed)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Jun 2017 at 06:33 UTC
Updated:
29 Nov 2018 at 20:04 UTC
Jump to comment: Most recent, Most recent file




Comments
Comment #2
jrockowitz commentedComment #3
simohell commentedPatch #143 from https://www.drupal.org/node/2174633 works (tested with Drupal 8.3.7) with Webform element Entity autocomplete. It does not appear to work with Entity radios, Entity select or Entity checkboxes.
The same patch does work with Content type's Entity reference fields using any of the widgets: Autocomplete, Select list, Autocomplete (Tags style), Check boxes/radio buttons
Comment #4
zenimagine commentedI applied patch number 174, it works fine with Drupal 8.4 but it does not work with Webform.
Comment #5
ericmaster commentedI tracked down to call to
$options = self::translateOptions($options, $element);insrc/Element/WebformEntityTrait.phpto be the one that overrides the Entity select values. If someone is willing to put some time create a patch we'll appreciate (I'll see if I can do myself later).Comment #6
clemens.tolboomComment #7
clemens.tolboomTesting core I learned 8.5.x and 8.6.x should work with #2174633-206: View output is not used for entityreference options
D8.5 needs #2174633-190: View output is not used for entityreference optionsD8.6 needs latest #2174633: View output is not used for entityreference options
Comment #8
clemens.tolboomI'm not sure why unwinding the options and translate those. And why the trait states
Attached patch is as below (commenting out loading translated nodes).
Please provide some manually test suggestions!
Comment #9
clemens.tolboomHmmm ... above was not a wise call. I was testing checkboxes.
Removing the lines in #8 results into a select containing HTML
Fixing the view result is IMHO too late as $options contains rendered view result which are then escaped.
Comment #10
clemens.tolboomAfter some debugging I did not found a direct solution. The options when coming from views should be typed as safe while user input must be cleaned somehow.[edit] option is not allowed any other content but text https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option [/edit]
Comment #11
ericmaster commentedThe override which wouldn't allow to display custom output comes from this line specifically
We should probably assume that field output coming from view is already translated. Added a condition for checking wether the selection handler is coming from a view and generated a patch that just strip tags, which should take care of wrapping tags issue, although I think this can also be fixed through views configuration.
Comment #12
ericmaster commentedComment #13
jrockowitz commented@Ericmaster The patch makes sense, but we should not call ::translateOptions when the entity select is 'views'.
The Views 'Entity Reference' display should be responsible for stripping HTML tags for the option text.
The below statement should be added to \Drupal\webform\Element\WebformEntityTrait::setOptions
Comment #14
jrockowitz commentedThe attached patch, hopefully, is the simplest solution. If someone can review and mark this ticket RTBC, I will commit it.
Comment #16
jrockowitz commentedI committed the patch. Please download the latest dev release to review.
Comment #18
akalata commentedJust a note that even with the committed Webform patch, the Core patch referenced in #7 must still be applied.