Using rules on data not inside the form
Evening,
I've want to make a field unique, but only within a subset. For example, if I am adding a Tag name, but I want that unique within a Type, but other Types could have the same name.
I don't record the Type on the form, I add that to the DB using the
->mutateFormDataUsing
method.
So how do I make something like
Not that you can get $data in the unique()
method, but cdt_type
definitely not in $get2 Replies
I don't understand everything honestly so I might be wrong
Tho it looks like you can add a hidden readonly field to get your type or add custom validation after the form submission
If your custom validation fail you can throw a
ValidationException
with a custom message and it will show it in red like any field would for a ->required()
for exampleThanks for the suggestion. I thought about that, then you've still got to pass the data somewhere in CreateAction.
My resolution was to actually something I should have thought of before, which was to go direct to get the information I previously wanted to pass, within the form:
->where('cdt_type', enumCdtType::from($livewire->activeTab)->value)