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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gpikelis created an issue. See original summary.

gpikelis’s picture

Issue summary: View changes
jrockowitz’s picture

Status: Active » Needs review
FileSize
1.92 KB
3.58 KB

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

gpikelis’s picture

I 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

gpikelis’s picture

Looks ok now.

jrockowitz’s picture

  • jrockowitz committed ac3386b on 8.x-5.x
    Issue #2959464 by jrockowitz: Likert questions defaults to answers with...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.