Hello,
I have an issue with the card choice layout. Consider the following code:
a!cardChoiceField( label: "What's the number of possible answers?", labelPosition: "ABOVE", data: { a!map( id: 2, icon: "dice-two", primaryText: "2", secondaryText: "Two" ), a!map( id: 4, icon: "dice-four", primaryText: "4", secondaryText: "Four" ) }, cardTemplate: if( rule!UNI_FN_getPageWidth() = 1, a!cardTemplateBarTextJustified( id: fv!data.id, primaryText: fv!data.primaryText, secondaryText: fv!data.secondaryText, icon: fv!data.icon ), a!cardTemplateTile( id: fv!data.id, primaryText: fv!data.primaryText, secondaryText: fv!data.secondaryText, icon: fv!data.icon ) ), value: local!numOfAnswers, saveInto: { a!save( local!numOfAnswers, save!value ) }, maxSelections: 1, required: true, requiredMessage: local!referenceData.requiredMessage )
The problem I'm facing is the fact that the choice is saved into a local variable as an array with one item instead of just an Integer.
This is my default value:
And these are the values I get when I choose a card:
I know that I can just access index 1 of this variable to access the expected integer value, but I don't understand why this is happening and whether or not I can force the component to save the correct value.
Discussion posts and replies are publicly visible
I think saving the selection in the form of an array is the default behaviour of card choice layout.Moving on to the next question, yes we can force the component to save the correct value by using index function inside the saveInto parameter.
a!save( local!numOfAnswers, index(save!value, 1, null()) )
Thank you! That helps a lot.