make repeater validation
I have Repeater where i can add many blogs. this blogs has amount. this blogs amount sum should not be more then
sum amount
. I want to make validation if first brand amount is 500 and second brand amount i wrote 300 and sum amount
=== 600 second brand amount should have erorr that max value is 100. there is my code:
29 Replies
anyone can help?..
Your code blocks should start with 3 x ` and then php so it formats it in php code block.
You need to explain more what you want. I am not following your issue.
@gigiloouu For the next time: Please don't open mutilple threads for the same issue.
I think you can use the
mutateDataBeforeSave
hook on the form to manually validate the data and throw a Validation Exception. That's probably the only waysorry, i just wanted to write my problem more detail
okay thanks i will try..
u mean use
mutateFormDataBeforeCreate
becouse i cant find any function or article about mutateDataBeforeSave
Yes
i try and google but i cant do it can u help me with that?
i read this already
and when i wrote this function
its not working.
like i try to just dd(); data
but not working
i mean im getting data but
i dont have brands data
im using pivot table for brands
ahh it won't work, ennis is slightly wrong as it's relationship data it's kept out of it, I think you need a different method.
hm for another task i just use maxValue and next i wrote some logic to see max value what will be but
at this moment
I have no idea how many brands will be becouse u can add as many as u wish
can u give me some idea or hint what will be good for this issue 😢
So what is the overall goal you are trying to achieve?
okay
i will tell u
Please try to write as clear as possible.
I have
purchase
table where i have Sum Amount
also
purchase
have brands, becouse of brands is many to many i use pivot table
u can click
add blog
and its add new feal for new brand
all brands has their own amount
so all this brands amount
should be equal of this sum amount
like if brands amount
is more then sum amount
we should have a error
if its less should be error
it should be equalWhere is sum amount entered? Earlier in the form?
brands amount
sum should be equal of sum amount
form looks like this
i can make
sum amount
earlier
its not a problemSo use a custom validation rule?
Or similar to that.
i have error in there
i should change empty are of false ?
git it a try, it's just a rough free hand code up from memory. But gives you the runderstanding.
see: https://filamentphp.com/docs/3.x/forms/validation#custom-rules
for the docs
thats works
thanks u soo much ❤️
for ur time ❤️