How it the repeater data loaded?
I'am trying to add support for the repeater field in Lunar (https://lunarphp.io/). the primitive field are already implement and i got the repeater working but on page load the data is not shown. But when I hit the add button the data is visible see screenshots. How is the data loaded? And way is it nog showing the contents on load?


12 Replies
your repeater is collapsed by default? (->collapsed)
Nope, see my configuration

What is RepeaterField?
LunarPhp allows you to extend its admin (Filament) with custom fields. You can find more information in the documentation: https://docs.lunarphp.io/admin/extending/attributes.html. They provide some basic fields and guidance on how to add your own. I am trying to implement a custom field using a Filament repeater. You can view the file here: https://github.com/cdsmths/lunar-filament-repeater-field/blob/main/src/Fields/RepeaterField.php. I have this working, but the repeater is not populated on load. I am exploring whether there is a hook to trigger this.
Hmm. As long as the name of the repeater in make() matches the model attribute it should load the data fine. Can you dump the state in ->afterStateHydrated() to make sure it is getting read in correctly on the field initialization.
It’s weird that the add would cause it to hydrate correctly though.
How is the data loaded?It justs uses an array of data from the model attribute you specify.
I think you mean this:


I meant dump the state in the method, to see that it’s coming from the model correctly when it’s loading.
Ah ok - But how to do this? I treid this useing ->afterStateHydrated but it's not called.

Ah got it!
It was a lunar implementation issue. Thank for you help! 🙏
GitHub
Can not implement a Filament Repeater as attribute field · Issue #2...
Lunar version: v1.0.0-beta.4 Laravel Version: v11 PHP Version: 8.3.15 Database Driver & Version: Mysql Expected Behaviour: I can use the Filament Repeater field to create more complex data stru...