About Radio Button and Check box

Now I am typing correct answer but i want like I want to select answer if one answer then it must come in radio button to  select the correct answer and if multiple answer means check box must to select multiple answer and in data all questions are mixed with single answers questions and multiple answers questions. so how to give radio button and check box

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Senior Developer
    in reply to akhilap

    In the foreach evaluation for your choice values and choice labels, get the values by using wherecontains. You have to get the answers related to your question so use the Parent data identifier to search the answers and it will automatically give you what is need.

    a!forEach(
        items: local!question,
        expression: a!boxLayout(
          label: fv!item.Question,
          contents: {
            a!textField(
              value: if(
                fv!item.isMultiple,
                "Multiple Choice",
                "Single Choice"
              ),
              readOnly: true
            ),
            if(
              fv!item.isMultiple,
              a!checkboxField(
                choiceValues: index(
                  local!answers.id,
                  wherecontains(fv!item, local!answers.questionId),
                  null
                ),
                choiceLabels: index(
                  local!answers.Answers,
                  wherecontains(fv!item, local!answers.questionId),
                  null
                ),
                
              ),
              a!radioButtonField(
                choiceValues: index(
                  local!answers.id,
                  wherecontains(fv!item, local!answers.questionId),
                  null
                ),
                choiceLabels: index(
                  local!answers.Answers,
                  wherecontains(fv!item, local!answers.questionId),
                  null
                ),
                
              )
            )
          },
          marginBelow: "MORE",
          style: "ACCENT"
        )
      )


    you can see how it is used in the choice values and choice labels of the components

Children
No Data