Question T7141
Visible to All Users

Feature Request - Option to get checkbox value as String instead of String array when we set "maxSelectedChoices":1

created 4 years ago

Hi Team,

I am having a scenario where the checkbox has only 1 choice - like for questions like "I agree to terms & conditions" , "check to receive email communications" etc.

So, I wanted to check if it's possible to get the value as String instead of String Array if there's only 1 choice or if "maxSelectedChoices" is set as 1.

Earlier, we used "boolean" type to cater this scenario but since the UI for boolean type got changed now to appear like switch/toggle - so, we have to go with checkbox type itself.

I understand, we use checkbox for capturing multiple choices but just wanted to check if anything can be done since we need the UI to look like the checkbox.

Thanks & Regards,
Akhil

Answers approved by surveyjs Support

created 4 years ago

Hello,

I believe you can use the boolean question type with the following configuration:

JSON
{ "type": "boolean", "name": "question4", "title": "I agree", "titleLocation": "hidden", "renderAs": "checkbox", "label": "I agree" },

Thanks, Serge
SurveyJS Team

    Comments (1)

      Hey Serge,

      I missed out this renderAs prop earlier. This workaround will do for me.

      Many thanks for your prompt response.

      Regards,
      Akhil