surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.21k stars 814 forks source link

storeOthersAsComment at question level #5788

Closed masciugo closed 5 months ago

masciugo commented 1 year ago

Are you requesting a feature, reporting a bug or asking a question?

question

What is the current behavior?

I'd like to control storeOthersAsComment prop at question level and it actually works. But looking at the docs it seems you can do that at survey level only. By looking the codebase, also seems to confirm the fact that it can be used at question level

Can you confirm that? If so maybe that prop is missing in the question baseselect docs

thank you

masciugo commented 1 year ago

most likely linked to #1635

JaneSjs commented 1 year ago

Hello @masciugo, Please accept my apologies for the delayed reply. It appears that I missed this issue. Yes, it is actually possible to specify the storeOthersAsComment property at the question's level. Consider this example:

{
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
     "type": "checkbox",
     "name": "question1",
     "choices": [
      "Item 1",
      "Item 2",
      "Item 3"
     ],
     "showOtherItem": true,
     "storeOthersAsComment": false
    },
    {
     "type": "checkbox",
     "name": "question2",
     "choices": [
      "Item 1",
      "Item 2",
      "Item 3"
     ],
     "showOtherItem": true,
     "storeOthersAsComment": true
    }
   ]
  }
 ]
}

We will check to see if we can better hightlight this in our documentation.

Thank you

JaneSjs commented 1 year ago

Hello @masciugo, I reviewed this thread (https://github.com/surveyjs/survey-library/issues/1635) and it appears that we intentionally marked the question.storeOthersAsComment property internal to avoid ambiguity when specifying both a survey's and question's storeOthersAsComment option. Therefore, we recommed that you specify the survey.storeOthersAsComment property at the survey level. Would you please clarify what is the usage scenario behing specifyign a different storeOthersAsComment value for survey questions?

I look forward to your reply.

Thanks

masciugo commented 1 year ago

Hi, I need to control storeOthersAsComment at question level when I need to apply my custom widget. Specifically I need to set storeOthersAsComment to false because the comment way is not compatible with with my custom widget. So it's not set by the user who build the survey model but forced, behind the scenes, by my custom widget code

JaneSjs commented 5 months ago

Hello @masciugo, Thank you for the clarification. You can actually override the storeOthersAsComment property at the level of an individual question instance. For instance, check our custom-widgets demo and review that the storeOthersAsComment setting is registered for a custom widget: view source code.

Please let us know if you have further questions.