Collapse Repeaters based on $state or with JS
Hello. I have "Orders". They have many "Items" so I use
I guess you can't use
So how can I collapse each item individually based on
EDIT: Actually I want them to be collapsed (or automatically collapsed onLoad) if
In the browser, the "done" filed is a switch, so...
I've tried with JS, but can't figure how to. I was able to get this far using ChatGPT, but I think it does a worse job than I do:
The image below is from my
Repeater::make.I guess you can't use
$state since Collapsible applies to the repeater not to each individual item.So how can I collapse each item individually based on
$state['done'].EDIT: Actually I want them to be collapsed (or automatically collapsed onLoad) if
done=true, not collapse them with a button.In the browser, the "done" filed is a switch, so...
I've tried with JS, but can't figure how to. I was able to get this far using ChatGPT, but I think it does a worse job than I do:
The image below is from my
OrdersResouce.php
Solution
Hey, i looked into Laravel 4.x docs and they added more utilities.
Looking at the https://filamentphp.com/docs/4.x/forms/repeater#collapsing-items table, nothing working for me.
But looking into https://filamentphp.com/docs/4.x/forms/repeater#adding-a-label-to-repeater-items-based-on-their-content table, I noticed "item" param. And it worked:
PS:
I had to remove some incompatible plugins to update to Filament 4 beta to try this.
Then, I discarded all the changes and went back to 3.x just to confirm it also works even while not stated in the 3.x docs.
So this is the current solution so far; using
Looking at the https://filamentphp.com/docs/4.x/forms/repeater#collapsing-items table, nothing working for me.
But looking into https://filamentphp.com/docs/4.x/forms/repeater#adding-a-label-to-repeater-items-based-on-their-content table, I noticed "item" param. And it worked:
PS:
I had to remove some incompatible plugins to update to Filament 4 beta to try this.
Then, I discarded all the changes and went back to 3.x just to confirm it also works even while not stated in the 3.x docs.
So this is the current solution so far; using
$item->model->ATTRIBUTE