Default repeater items not working

Hello. I have an action button on a table to send an email. It opens a form to write the subject and type receivers. I need to fill in two different receivers by default, but it is not working.
Action::make('sendEmailToFactory')->label('')->modalDescription('send email to factory')
->form([
TextInput::make('subject')
->label('Email Subject:')
->default(fn ($record) => 'Production Order ' . $record->id)
->required(),
TableRepeater::make('emails')
->label('Destination emails:')
->default([
['email' => '[email protected]',],
['email' => '[email protected]',],
])
->schema([
TextInput::make('email')
->label('Destination email:')
->email()
->required(),
])->defaultItems(2)->minItems(1)->addActionLabel('Add more emails'),
Action::make('sendEmailToFactory')->label('')->modalDescription('send email to factory')
->form([
TextInput::make('subject')
->label('Email Subject:')
->default(fn ($record) => 'Production Order ' . $record->id)
->required(),
TableRepeater::make('emails')
->label('Destination emails:')
->default([
['email' => '[email protected]',],
['email' => '[email protected]',],
])
->schema([
TextInput::make('email')
->label('Destination email:')
->email()
->required(),
])->defaultItems(2)->minItems(1)->addActionLabel('Add more emails'),
Please, any ideas of how to achieve this? I have tried with Repeater:: and also with TableRepeater:: Tks.
Solution:
```php ->modalDescription('send email to factory') ->fillForm([ 'emails' => [ ['email' => '[email protected]'],...
Jump to solution
2 Replies
Solution
toeknee
toeknee3mo ago
->modalDescription('send email to factory')
->fillForm([
'emails' => [
['email' => '[email protected]'],
['email' => '[email protected]'],
]
})
->modalDescription('send email to factory')
->fillForm([
'emails' => [
['email' => '[email protected]'],
['email' => '[email protected]'],
]
})
Albert Lens
Albert LensOP3mo ago
It works, though it fills only emails but leaves blank subject and contents (which had a default value) Anyway, I have put all default values in fillForm like this:
->fillForm(fn ($record)=>[
'emails' => [
['email' => '[email protected]',],
['email' => '[email protected]',],
],
'subject' => 'Production Order ' . $record->id,
'contents' => 'We are hereby attaching our Production Order ' . $record->id . ' for immediate production.'
])
->fillForm(fn ($record)=>[
'emails' => [
['email' => '[email protected]',],
['email' => '[email protected]',],
],
'subject' => 'Production Order ' . $record->id,
'contents' => 'We are hereby attaching our Production Order ' . $record->id . ' for immediate production.'
])
Thank you very much for your help, mate.
Want results from more Discord servers?
Add your server