A likert defined with a value that exists and is valid, but also is considered empty by the "empty()" function will fail validation in. A common value would be "0". I'm not sure if it is possible to define any other valid values, such as the empty string''.

Existing validation:

        if (empty($value[$question_key])) {
          $form_state->setError(...);
        }
Should be:
        if (is_null($value[$question_key])) {
          $form_state->setError(...);
        }

Patch forthcoming.

CommentFileSizeAuthor
#2 3052722-2.patch623 bytesdanchadwick

Comments

DanChadwick created an issue. See original summary.

danchadwick’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new623 bytes
webapp's’s picture

Hi @DanChadwick

I think it's a good catch. the patch looks good for me.

BTW here is the link I followed. It may be useful for reference.
https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/

Thanks

jrockowitz’s picture

Status: Needs review » Fixed

@webapp's comment makes this RTBC, so I committed the patch. Thanks @DanChadwick for the patch and @webapp's for the code review.

danchadwick’s picture

@jrockowitz - My gratitude to you, the hard-working maintainer!

Status: Fixed » Closed (fixed)

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