Question T2063
Visible to All Users

Default value for signature isn't displayed if Signature have visible if condition

created 6 years ago

Hello

There is an issue with default value for signaturePad and visibleIf condition.

Here is an example:
https://codesandbox.io/s/fervent-shockley-4c7m0

You can see that survey has 3 types of questions: text input and two signatures. Both of signatures are the same, have the same default value, but field2 has visibleIf condition: {field1} notempty. On the test tab you can see that field3 displays defaultValue, but if you give some value to the field1 - field2 shows without default value.

Answers approved by surveyjs Support

created 6 years ago

Hello,

This question is related to all survey elements, not to the SignaturePad only.
In order to implement complex scenarios question values can be cleared in the onVisibleChanged event handler:

JavaScript
var questionsCleanOnHide = ["kid2Age", "kid3Age"]; // put here names of questions that should be cleared. Custom property `clearOnHide` can be use in more common scenario survey .onVisibleChanged .add(function (sender, options) { if(!options.visible) { if(questionsCleanOnHide.indexOf(options.name) !== -1) { options.question.value = undefined; } } });

Here is the workling sample - https://plnkr.co/edit/NfDr7jeFxRkvNh2M8NiA?p=preview

Thanks, Serge
SurveyJS Team

    Show previous comments (4)
    AB AB
    Anton Balandin 6 years ago

        Hello,

        The editor.survey and survey in test tab are different ones.
        You need to use the onTestSurveyCreated event to subscribe the onVisibleCnaged event.
        I've updated your code - https://codesandbox.io/s/adoring-cherry-ppgx3

        Thanks, Serge
        SurveyJS Team

        AB AB
        Anton Balandin 6 years ago

          Ok, I understand my mistake. Thank you!

          created 6 years ago

          Hello,

          You've set

          JSON
          clearInvisibleValues: "onHidden"

          in your survey JSON. That's why hidden question value is reset.

          You can use "none" or "onComplete" values to override this behavior.

          Thanks, Serge
          SurveyJS Team

            Comments (3)
            AB AB
            Anton Balandin 6 years ago

              But I used this setting to solve this question: https://surveyjs.answerdesk.io/ticket/details/t1887

              AB AB
              Anton Balandin 6 years ago

                We need both cases working. Can it be fixed?

                AB AB
                Anton Balandin 6 years ago

                  Maybe this setting can be applied for question only, not globally?