Question T16927
Visible to All Users

Radiogroup value with - does not work as default value

created a year ago (modified a year ago)
  • add a simple radiogroup
  • add 2 values both with a - like survey-dashboard, survey-table
  • try to copy paste the value and set it as default value
  • BUG: does not work
  • Unexpexted solution: use double quotes for the default value: "survey-dashboard"

Clipboard-File-1.png

OK, radiobutton is checked:

Clipboard-File-3.png

Bug, radio is not checked:

Clipboard-File-4.png

Answers approved by surveyjs Support

created a year ago

Hello Wolfgang,
If you wish to specify the default value expression and set it to a string literal, please enclose a string literal within single quotes. Please consider the following demo:

JSON
{ "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "radiogroup", "name": "question1", "defaultValueExpression": "'item-one'", "choices": [ "item-one", "item-two" ] } ] } ] }

Let me know if this works for you.

    Comments (2)

      Sure that works but is unexpected because it is already a string. Why are single-quotes necessary?

        Hello,
        The defaultValueExperession accepts an expression rather than a plain string. Therefore, simply pasting a string won't work. You need to use a string literal within the default value expression.

        Please let me know if you require additional clarification.