Issue T420
Visible to All Users

Bug with default values on text and dropdown fields inside dynamic panels

created 7 years ago (modified 7 years ago)

Text and Dropdown type fields which have a default value do not show the default value during the survey.

Replicate by creating a survey with a text field and dropdown field then assign them default values and testing the survey in the editor

Comments (2)

    Just have checked this on our site - https://surveyjs.io/Survey/Builder/ - with this JSON:

    Code
    { pages: [ { name: "page1", elements: [ { type: "text", name: "question1", defaultValue: "ddd" }, { type: "dropdown", name: "question2", defaultValue: "item2", choices: [ "item1", "item2", "item3" ] } ] } ] }

    Works like a charm for me. Am I missing somethig?

      Sorry wrong test case. Inside a dynamic panel it doesn't work.

      See below

      JavaScript
      { "pages": [ { "name": "page2", "elements": [ { "type": "paneldynamic", "name": "question1", "templateElements": [ { "type": "text", "name": "question2", "defaultValue": "100" }, { "type": "dropdown", "name": "question3", "defaultValue": "item2", "choices": [ "item1", "item2", "item3" ] } ] } ] } ] }

      Answers

      created 7 years ago

      Hello Justin,
      The bug has been reproduced in a Unit Test and fixed: https://github.com/surveyjs/surveyjs/issues/910
      The fix will be available in the next minor update.

      Thank you,
      Andrew
      SurveyJS Team

        Comments (3)

          Hi Andrew, I can still see this issue in the editor on your website.

          See the JSON below

          {
          "pages": [
          {
          "name": "page1",
          "elements": [
          {
          "type": "paneldynamic",
          "name": "question2",
          "titleLocation": "hidden",
          "templateElements": [
          {
          "type": "text",
          "name": "blah blah",
          "defaultValue": "5545",
          "titleLocation": "hidden"
          },
          {
          "type": "dropdown",
          "name": "question1",
          "defaultValue": "item2",
          "choices": [
          "item1",
          "item2",
          "item3"
          ]
          }
          ],
          "panelCount": 1,
          "minPanelCount": 1
          }
          ]
          }
          ]
          }

            Indeed it doesn't work. I will work on it right now.

            Thank you,
            Andrew
            SurveyJS Team

              Sorry about that. I have added a unit test for knockout and fixed it. The knockout observal value doesn't update on changing the question value in this particular case and as result it doesn't work in knockout, jquery and angular.
              It is fixed with this commit: https://github.com/surveyjs/surveyjs/commit/074ff3c5b42094438e996e74887e26df06959e30
              We will release a new minor on this week. Maybe event today.

              Thank you,
              Andrew
              SurveyJS Team