how to set a value of an input field using values in a repeater
I have this input fields inside a repeater, product name, price and quantity, and I have an input field total disabled by default outside of the repeater, I want to populate the result of
foreach(price * quantity)
inside the total fieldSolution:Jump to solution
myabe you can add the afterStateUpdated directly to the repeater instead of the input fields. Try using
->afterStateUpdated(fn ($state) => dd($state))
on the repeater and examine the results. It should be an array with all the items in the repeater. This will fire when you click the add
action of the repeater and when you update items in the repeater. New empty items have a uuid key. But I imagine you can easily traverse the array, make calculatioins and set the value to the total. Let me kn...9 Replies
my codes look like this
i tried implemting like this from an idea got from this discussion
https://github.com/filamentphp/filament/discussions/5351
but its still not working, using ../.. is in v2 i don't if it can still be used in v3
GitHub
Set value of a field that is outside the repeater field, from a fie...
I'm trying to update the value of a field that is outside a repeater from a field that is inside the repeater, but the calculated value is doubling. For example, if I type 2 in the quantity fie...
it works with this but the problem when more that a single product is order for
Interesting 🧐 I’ve never used the
../
notation before. I’ll do some testing myself and let you knowOk thanks, i await ur findings
Solution
myabe you can add the afterStateUpdated directly to the repeater instead of the input fields. Try using
->afterStateUpdated(fn ($state) => dd($state))
on the repeater and examine the results. It should be an array with all the items in the repeater. This will fire when you click the add
action of the repeater and when you update items in the repeater. New empty items have a uuid key. But I imagine you can easily traverse the array, make calculatioins and set the value to the total. Let me know if that worksLet me test it out
@Obala if you don't mind, I'm marking this as solved since its been a few weeks since the last update
Oh yah totally forgot
I have another though in Laravel , hope you can take a look at it, on middleware