Form Repeat (make sure of unique inputs only)

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.

  1. 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.

  2. 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.

  3. 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

Community Page
Last updated: