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