Question T5391
Visible to All Users

Survey-creator: update default option values

created 4 years ago

hello Team,

We would like to change default option values on dropdown/checkbox/radio button. The approach I am using right now is
surveyBuilder.onQuestionAdded.add(function(sender, options) { options.question.title = "Untitled " + options.question.getType() +". Please enter question title here."; if(["radiogroup", "checkbox", "dropdown"].includes(options.question.getType()) && Array.isArray(options.question.choices)){ options.question.choices.forEach((choice, index) => { choice.value =Insert option ${index} here.; }); } });

But this has issues when copying questions. This is overriding the copying items

Show previous comments (4)

    Unfortunately, creator.onModified event will be fired after. You can replace the toolbox items jsons. Here is the example that actually shows exactly what you need - overrides choices for dropdown/checkbox/radiogroup.

    Thank you,
    Andrew
    SurveyJS Team

      Frankly, this is what I need :D

        Hello,

        As I understood the problem is resolved. Fine! Feel free to contact us in case of any further questions

        Thanks, Alex
        SurveyJS Team