Composite Key validation when saving a record
I have the following components on the form of relation manager class
How can I validate unique combination selection for the parent resource when saving the form?
10 Replies
Basically, the selection for
option 1 / option 2 / option 3
needs to be unique for the parent relation
any advice on this please?
@awcodes any advice on this.maybe?
where do I set this?
so do I add this rule to all the 3 fields?
don't know, haven't needed it. just try it.
it is confusing though, not gonna lie
you're trying to unique across tables though, so i'm not sure there is a good way to do this.
the problem with the above is, the uniqueness for the parent id isn't set
the table has
these are the 4 columns and I am trying to find option value combination for the parent_id
yea, i'm understanding. You're probably going to have to do a custom rule for this. https://laraveldaily.com/post/laravel-unique-validation-multiple-columns
Laravel Daily
Laravel Unique Validation for Multiple Columns
but it'll probably get fairly complicated with each 'option' being a separate relationship and table.
as long as the query is correct it should work though.
ok, let me give it a try