Conditional Validating a form with a repeater
I have a form with a
select
field and a repeater with 3 other fields. The select
element is to select pre-existing data and the repeater
is to add new data. How can I validate if one them has a value. The user can either pick a value from the select
field or add a new item in the repeater or do both. What is a good way to validate something like this? I am using the standalone form builder and here is what I have
Not quite sure on how to validate the above login on the action
method12 Replies
any advice on this is appreciated
So if there is a value in the Select, the Repeater is not needed, and vice versa?
Correct, there is also chances that they select something on the
Select
and add on the repeater if the value did not existbasically the form looks like this
What should happen if both the Select and Repeater have values? Can this sometimes be valid or never?
yes, that is valid too
I'm not sure I understand what you want to validate then? lol maybe I'm just missing some context.
if both the fields don't have values, it doesn't validate
aaah yes, ok
Maybe
requiredWithout()
on both the Select and Repeater?
https://filamentphp.com/docs/3.x/forms/validation#required-withoutok
let me try that
for the select field, how do I use the
requiredWithout
to indicate atleast 1 item in the repeater is required?Not sure actually... maybe this?