F
Filamentβ€’15mo 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
YaegerOPβ€’15mo ago
No description
Yaeger
YaegerOPβ€’15mo ago
seems broken πŸ‘€ Quite a basic setup:
Yaeger
YaegerOPβ€’15mo ago
No description
Solution
LeandroFerreira
LeandroFerreiraβ€’15mo ago
$form->statePath('data')
Yaeger
YaegerOPβ€’15mo ago
Hero It was working for every other field, but I guess for repeater it's needed to define state path
Yaeger
YaegerOPβ€’15mo ago
Thanks!
LeandroFerreira
LeandroFerreiraβ€’15mo ago
You should declare all fields public $test; public $test2;... Or use statePath instead of this
Yaeger
YaegerOPβ€’15mo ago
Do you by any chance also know how defaultItems() works?
No description
Yaeger
YaegerOPβ€’15mo ago
It's not putting any default items
No description
Yaeger
YaegerOPβ€’15mo 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
Want results from more Discord servers?
Add your server