FilamentF
Filament14mo ago
Bekhruz

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();
    }
photo_2024-10-31_19-31-26.jpg
photo_2024-10-31_19-31-26_2.jpg
photo_2024-10-31_19-31-26_3.jpg
Was this page helpful?