Relation Manager: Create with Modal. How to define default values for form fields?

How and where to put my predefined values?
$this->form->fill([
'start_date' => now()->format('Y-m-d'),
'frequency' => 'WEEKLY',
'weekdays' => ['WE', 'FR'],
'start_time' => '10:00',
'count' => 100,
'slots_available' => 1,
'duration_unit' => 'M',
'duration_value' => 90,
]);
$this->form->fill([
'start_date' => now()->format('Y-m-d'),
'frequency' => 'WEEKLY',
'weekdays' => ['WE', 'FR'],
'start_time' => '10:00',
'count' => 100,
'slots_available' => 1,
'duration_unit' => 'M',
'duration_value' => 90,
]);
I tried
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
But cant get it to work. In EditAction it works perfectly with:
EditAction::make()
//Antes de llenar el formulario, adaptar/mutar los datos.
->mutateRecordDataUsing(function (array $data): array {
return FormMutatorHelper::mutateBeforeAvailabilityFormData($data);
})
//Antes de guardar, adaptar/mutar los datos.
->mutateFormDataUsing(function (array $data): array {
return FormMutatorHelper::mutateAvailabilityFormData($data);
}),
EditAction::make()
//Antes de llenar el formulario, adaptar/mutar los datos.
->mutateRecordDataUsing(function (array $data): array {
return FormMutatorHelper::mutateBeforeAvailabilityFormData($data);
})
//Antes de guardar, adaptar/mutar los datos.
->mutateFormDataUsing(function (array $data): array {
return FormMutatorHelper::mutateAvailabilityFormData($data);
}),
`
2 Replies
sumardi
sumardiβ€’2y ago
CreateAction::make()
->mountUsing(function ($form) {
$form->fill([
//...
]);
});
CreateAction::make()
->mountUsing(function ($form) {
$form->fill([
//...
]);
});
Falk Maria Zeitsprung
Falk Maria ZeitsprungOPβ€’2y ago
Thanks very much @sumardi πŸ™
Want results from more Discord servers?
Add your server