Just want to get some ideas of what possible solutions others may have.
So i have a form repeat element on my form, inside it is a select dropdown with 3 different choices.
The dropdown in populated from another database query all together.
Currently the user could add all 3 to their list of choices and choose the same item all 3 times, and it would create 3 identical entries inside the sub table.
As you can see Kayak Guide has been added twice by mistake.
I see 3 possible solutions.
it would be awesome if after the user chooses Kayak Guide, then that choice is no longer available in their next dropdown, kind of like how tagify works, where once an option is chosen, its not available again. I did not use tagify for this UI as there is a hidden input that stores a priority as well, that is important for me to know.
On submit of the form, the server action strips out the duplicate values and only sends unique ones to the insert, i have tried using the groupby fillter, but can not seem to get it to do exactly what i want, i also tried the unique formatter but then i loose my priority input, so neither really give me a subtable insert with only 2 unique entries with their set priority which is just the $index of the form repeat.
Before submit, a client side validator checks and warns of duplicate values, like a NOT Equal / In Array validation.
Anyone got some better plans on how to best do this, maybe there is a way i could also use tagify but have it return the value of the chosen tag as well as its position in the array as its priority, even though i do not think it would be a very intuitive user UI.
Even the documentations example, where there is a USER / Contacts table relationship and standard text inputs, a user could enter multiple contacts with duplicate email addresses, and because of the way it inserts into the subtable, i do not see a way to add a validate step or something before each insert, so maybe i am missing something
As far as I understand, you have a form repeat containing an input select and a button that adds more selects in your form (up to 3 selects) .
First thought:
Can you use the select’s on_update event to check if this value has been used already.
Right way:
Where are the 3 choices of the selects coming from?
I suppose there must be a way to restrict the select’s source and exclude the already used values so the drop down shows only the remaining ones.
I kind of tried that already, but if i remove the selectedValue from the dataset then even the select which has been chosen removes its selection as all 3 selects use the same data source to the server connect database
The add button which is outside the repeat element will add as many new selects as the item count of the database query which is used as the source, so it could be only be 1 in some cases or it could be 50 in theory.
I am going to try use the items inside the formRepeat itself possibly as a way to filter the data sources as my next attempt.
I have come across the same situation where I want to remove the values that have been already selected in a form repeat. I’m using Tagify instead of select in the form repeat.
I have been unable to get this working with various methods I have tried. How did you solve this with the client-side array? Could you please provide some information on this setup? Your help is greatly appreciated.
First it would be nice to know what we are talking about…
This is for an Update or an Insert? I mean the form repeat comes already with ome saved values form a datasourse or you just start form scratch adding values via your tagify?
And your tagify I suppose it is a select one (only one value is acceprable)
Anyway the idea (IN MY CASE) was to add each selected value in an array AFTER I check on change event if that value is not already used…
In case of an update it means that you have first to fill up the array with the existing values, obviously on the success event of the source of your record datasourse (not the tagify datasourse…)
If I knew what we are talking bout exactly I could give more details
I have got it working. The formRepeat is for an insert and the tagify values (list available to the users) are being added to the form based on the user selection. Here’s a screenshot of the setup (with Tagify - Select Mode).
Many thanks for your help. I had been trying to find a method to achieve this and your solution worked perfectly