Default value error or problem with State

Hello, everyone! Please help me. I prepared this code and provided it with data without any issues, but for some reason, it's not working. If I remove the category_id error written inside beforeFill, it starts working, but when it's present, the data doesn't appear, only the default value. I thought there was a problem only with the default value, but it seems there's an issue with the state. EditProducts
protected function beforeFill(): void
{
$state = [];
$locales = config('app.locales');

foreach ($locales as $locale) {
$state['translations'][$locale]['name'] = $this->record->getTranslation($locale)->name ?? '';
$state['translations'][$locale]['description'] = $this->record->getTranslation($locale)->description ?? '';
}

$state['category_id'] = $this->record->category_id;
$state['price'] = $this->record->price;


$this->form->fill($state)->getState();
}
protected function beforeFill(): void
{
$state = [];
$locales = config('app.locales');

foreach ($locales as $locale) {
$state['translations'][$locale]['name'] = $this->record->getTranslation($locale)->name ?? '';
$state['translations'][$locale]['description'] = $this->record->getTranslation($locale)->description ?? '';
}

$state['category_id'] = $this->record->category_id;
$state['price'] = $this->record->price;


$this->form->fill($state)->getState();
}
No description
No description
No description
2 Replies
LeandroFerreira
LeandroFerreira2mo ago
If you want to modify data before it is filled, you should use mutateFormDataBeforeFill
Bekhruz
BekhruzOP2mo ago
Everything looks great, thank you so much!
Want results from more Discord servers?
Add your server