Form modification recovery problem
I can't retrieve changes from my edit form. Do you have a solution ?
protected function getSaveFormAction(): Action
{
dd($this->form->getState());
if (auth()->user()->artist->modify_number_invoice == 0) {
return Action::make('save')
->requiresConfirmation()
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->action(function ($data) {
// dd($this->form->getState());
$artist = auth()->user()->artist;
if ($artist->number_invoice != $data['number_invoice']) {
$artist->number_invoice = $data['number_invoice'];
$artist->save();
}
parent::save();
})
->modalHeading(
'Si vous confirmez, vous ne pourrez plus modifier le début de l\'indexation des numéros de la facture.'
)
->modalDescription(
'Êtes-vous sûr de vouloir utiliser ce numéro ?'
)
->form([
TextInput::make('number_invoice')
->label(__('artist-resource.field.number_invoice'))
->numeric()
->formatStateUsing(function () {
return auth()->user()->artist->number_invoice;
})
])
->submit(null)
->keyBindings(['mod+s']);
} else {
return Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save')
->keyBindings(['mod+s']);
}
}
protected function getSaveFormAction(): Action
{
dd($this->form->getState());
if (auth()->user()->artist->modify_number_invoice == 0) {
return Action::make('save')
->requiresConfirmation()
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->action(function ($data) {
// dd($this->form->getState());
$artist = auth()->user()->artist;
if ($artist->number_invoice != $data['number_invoice']) {
$artist->number_invoice = $data['number_invoice'];
$artist->save();
}
parent::save();
})
->modalHeading(
'Si vous confirmez, vous ne pourrez plus modifier le début de l\'indexation des numéros de la facture.'
)
->modalDescription(
'Êtes-vous sûr de vouloir utiliser ce numéro ?'
)
->form([
TextInput::make('number_invoice')
->label(__('artist-resource.field.number_invoice'))
->numeric()
->formatStateUsing(function () {
return auth()->user()->artist->number_invoice;
})
])
->submit(null)
->keyBindings(['mod+s']);
} else {
return Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save')
->keyBindings(['mod+s']);
}
}
0 Replies