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.
Likert elements pre-selects default values even if not asked for this.
I was struggling to find particular case, but finally nailed it down to example bellow.
epic_question:
'#type': likert
'#title': 'Your state recently?'
'#questions':
EPIC1: 'How was your mood last week ?'
EPIC2: 'How are you feeling today ?'
'#answers':
100: 'No problem'
50: 'Lite problem'
0: 'Big problem'
With this yaml, form opens with last answer selected by default
NOW.. if you change value from 0 to 1, it works as expected. No default selection in form.
Comment | File | Size | Author |
---|---|---|---|
#6 | 2959464-6.patch | 3.74 KB | jrockowitz |
| |||
#3 | webform.webform.issue_2959464.yml | 3.58 KB | jrockowitz |
#3 | 2959464-2.patch | 1.92 KB | jrockowitz |
|
Comments
Comment #2
gpikelis CreditAttribution: gpikelis commentedComment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI agree that this is a major issue.
The attached webform replicates the issue and the attached patch is a rough attempt at a solution. I want to see if it breaks any tests.
The handling of '0', empty strings, NULL, and N/A within a likert element is definitely going to require some additional test coverage.
Comment #4
gpikelis CreditAttribution: gpikelis commentedI will do some more testing, but funny thing is that same form runs fine on older version of Drupal and WebForms I have on one of the machines.
Drupal core 8.3.7
Webform 8.x-5.0-beta4
Comment #5
gpikelis CreditAttribution: gpikelis commentedLooks ok now.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented