F
Filament16mo ago
Yaeger

How does Repeater work?

When I press the button at the bottom, it just clears the first field. How do I get more than 1 item in the repeater? Is it broken? Or is it not doing what I thought it would be doing?
Solution:
$form->statePath('data')
Jump to solution
10 Replies
Yaeger
YaegerOP16mo ago
No description
Yaeger
YaegerOP16mo ago
seems broken 👀 Quite a basic setup:
Yaeger
YaegerOP16mo ago
No description
Solution
LeandroFerreira
LeandroFerreira16mo ago
$form->statePath('data')
Yaeger
YaegerOP16mo ago
Hero It was working for every other field, but I guess for repeater it's needed to define state path
Yaeger
YaegerOP16mo ago
Thanks!
LeandroFerreira
LeandroFerreira16mo ago
You should declare all fields public $test; public $test2;... Or use statePath instead of this
Yaeger
YaegerOP16mo ago
Do you by any chance also know how defaultItems() works?
No description
Yaeger
YaegerOP16mo ago
It's not putting any default items
No description
Yaeger
YaegerOP16mo ago
Is it it because of this note from the docs? "Note that these default items are only created when the form is loaded without existing data." Ah definitely, when I call fill() it seems to work I guess I missed this step:
Initialize the form with $this->form->fill() in mount(). This is imperative for every form that you build, even if it doesn't have any initial data.
Initialize the form with $this->form->fill() in mount(). This is imperative for every form that you build, even if it doesn't have any initial data.
Slowly figuring things out haha, thanks for your patience

Did you find this page helpful?