I have an events calendar app and using Ionic/React/Flask. There is a form for submitting an event. I have an item where you can select the frequency of the event. When you could just choose one it worked perfectly. But now I've made it so that the user can select mutliple options:
<IonItem>
<IonLabel>Frequency</IonLabel>
<IonSelect value={EFreq} multiple={true} placeholder="Select One" onIonChange={e => setEFreq(e.detail.value)}>
<IonSelectOption value="Weekly">Weekly</IonSelectOption>
<IonSelectOption value="1st week">1st week of the month</IonSelectOption>
<IonSelectOption value="2nd week">2nd week of the month</IonSelectOption>
<IonSelectOption value="3rd week">3rd week of the month</IonSelectOption>
<IonSelectOption value="4th week">4th week of the month</IonSelectOption>
</IonSelect>
</IonItem>
When the user selects multiple options the state variable becomes an array like:
['1st week','2nd week']
When I send this to my Flask backend I get an error
Operand should contain 1 column(s)
I thought if I could somehow join the array elements like
1st week 2nd week that could work.
So I tried to take the state variable and join it like
SetEFreq(Efreq.join())
but haven't quite figured that out yet but am told that it's not great to change the type from an array to a string. It's error prone.
So right now I'm not sure how to handle this. Should I try and get my flask backend to accept the array? Should I find a way to alter the input so it is just a string that goes to the backend? Not sure what is the best approach. How do people do a multiple option form input with flask?