How to prevent already selected value in repeater?
I am using repeater to add working hours and I don't want users to select same day twice. How can I prevent this?
12 Replies
Are you using a select in the repeater? The only way I can think of is to get the variables in the repeater and query them on a custom rule
Yes, I am using select in the repeater. Can you please show how?
IIRC you can call the repeater name to get the array of elements with a closure in rules and pass it in to validate itv
Has the problem been resolved? I'm a bit lost on how to do that for Select Columns
So you would have to go through all the fields with a closure and check their values to ensure it’s not been selected.
I just want it to work like multiselect, which doesn't show the selection when it's already selected in another repeater. If using rules, won't it check it after the form is submitted (clicked submit)?
Validation is your best bet here. Think about it. A repeater uses the same fields when a new item is added, so if you remove an option from the select then it will no longer exist as an option in the places it’s already been set nulling those out.
Make sense now
I am doing this like below, this may not be perfect solution but its working for me.
Repeater:
Get days:
Good work
This is working very well, thank you
Hello, regarding this implementation, does the first select retain its selection when you add a new item? Because when I add a new item, the first selection disappears