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