Closed (won't fix)
Project:
Webform
Version:
8.x-5.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Jan 2018 at 13:47 UTC
Updated:
24 Feb 2020 at 00:32 UTC
Jump to comment: Most recent
Comments
Comment #2
jrockowitz commentedThe backend data storage of submission data can't support likerts with multiple values.
There is no easy workaround even with custom code.
You might be able to fake a Likert using checkboxes layed out horizontally and side-by-side
Comment #3
jrockowitz commentedComment #4
gpikelis commentedOK. Fair enough :)
In a way "table select" element saving data the way I need. So an array of table selects could be used to fake likert.
Is it possible to get it horizontal?
Comment #5
jrockowitz commentedFor the amount work needed to get a horizontal table select, I would create a new element or try to place my checkboxes elements in a container and theme it to look like a table.
Comment #6
rd.michael commentedI know this question is pretty old but I'm wondering if you can provide insight into creating a custom element. I've actually gotten something working but want to know if I'm on the right track or if there are any gotchas that I'm missing.
Drupal\webform\Element\WebformLikertI am overriding the methodprocessWebformLikertso that I can change the radio elements to the checkbox elements. The trick, I discovered, to get checkboxes sending the correct data to the server was to update the '#parents' key to a multi multi dimensional array. i.e.'#parents' => [$element['#name'], $question_key, $parent_inc]where$parent_incis simply a delta.valueCallbackmethod, simply to remove the conditional check foris_scalarand the casting of the value to a string (since it's now an array).WebformSubmissionStorageclass. I added a simple conditional for my element in the save and load methods. The reason I had to do this was b/c my values are sent in this format[question_id][property_id][delta]and there is no current conditional that stores things in that format. The closest I could find was the'#webform_composite'plus'#webform_multiple'both being true, but I'm not sure I can override the'#webform_multiple'value. In addition I would have to change my format from[question_id][property_id][delta]to[question_id][delta][property_id]and I'm not sure it makes sense to do that or if it's possible.Drupal\webform\Plugin\WebformElement\WebformLikertI overwrote theformatHtmlItemandformatTextItemmethods to account for the array values instead of expecting a scalar.All that to say, do you think I'm missing anything? And if not, would you be open to a patch if I could integrate this into the WebformLikert element (or a new element)?
Comment #7
jrockowitz commented@researchanddesign.michael Your solution makes sense. I am optimistic we could add support for #multiple property to the existing Likert element.
A patch would be welcomed but most likely not committed until Webform 8.x-6.x which I hope to start working on after the New Year.
Comment #8
jrockowitz commentedThe level of effort required to add another layer of complexity to how submission data is saved and loaded does not seem worth being able to support a multi-value Likert element.