Repeater `defaultItems()` not works

The Repeater displayed empty until pressing the add button. I want to display a specific numbers. As I know it's by setting it like ->defaultItems(2) but not works. Am I missing something?
Forms\Components\Repeater::make('blogs')
->schema([
Forms\Components\TextInput::make('title'),
])
->defaultItems(2),
Forms\Components\Repeater::make('blogs')
->schema([
Forms\Components\TextInput::make('title'),
])
->defaultItems(2),
3 Replies
awcodes
awcodesβ€’2y ago
are you on an edit page? I think this only works on create.
devfaysal
devfaysalβ€’2y ago
Add $this->form->fill(); in the mount method. I was facing a similar issue recently and found the solution in GitHub: https://github.com/filamentphp/filament/discussions/2851

public function mount()
{
$this->form->fill();
}

public function mount()
{
$this->form->fill();
}
GitHub
->defaultItems(1) on Repeater did not show empty row Β· filamentphp ...
Package filament/forms Package Version 2.13.7 Laravel Version 9 Livewire Version 2 PHP Version 8.1 Bug description Repeater::make('Chapters') ->relationship('chapters') ->form...
MohamedSabil83
MohamedSabil83OPβ€’2y ago
@awcodes Yes, on the edit page that's why. @devfaysal I'll try that. If not, then will make a custom page Thanks guys yep, it works πŸ‘πŸ½

Did you find this page helpful?