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?
No description
No description
12 Replies
hizmarck
hizmarck4w ago
your repeater is collapsed by default? (->collapsed)
Thomas van der Westen
Nope, see my configuration
No description
awcodes
awcodes4w ago
What is RepeaterField?
Thomas van der Westen
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.
awcodes
awcodes4w ago
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.
Dennis Koch
Dennis Koch4w ago
How is the data loaded?
It justs uses an array of data from the model attribute you specify.
Thomas van der Westen
I think you mean this:
No description
awcodes
awcodes4w ago
I meant dump the state in the method, to see that it’s coming from the model correctly when it’s loading.
Thomas van der Westen
Ah ok - But how to do this? I treid this useing ->afterStateHydrated but it's not called.
No description
Thomas van der Westen
Ah got it! It was a lunar implementation issue. Thank for you help! 🙏
Thomas van der Westen
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...

Did you find this page helpful?