jeffgreco13 / filament-breezy

MIT License
704 stars 130 forks source link

Overriding PersonalInfo doesn't work #322

Open DanielvdSpoel opened 7 months ago

DanielvdSpoel commented 7 months ago

I have this class to let users update their first_name and last_name as well, but as soon as I click update the component springs back to its original one and it says "The name field is required"


class PersonalInfo extends BreezyPersonalInfo
{
    public array $only = ['display_name', 'first_name', 'last_name', 'email'];
    protected function getProfileFormSchema(): array
    {
        return [
            Forms\Components\Group::make([
                Forms\Components\Grid::make()
                    ->schema([
                        Forms\Components\TextInput::make('first_name')
                            ->required(),
                        Forms\Components\TextInput::make('last_name')
                            ->required(),
                    ])
                    ->columns(2),
                Forms\Components\TextInput::make('display_name')
                    ->unique($this->userClass, ignorable: $this->user),
                Forms\Components\TextInput::make('email')
                    ->required()
                    ->email()
                    ->unique($this->userClass, ignorable: $this->user)
                    ->label(__('filament-breezy::default.fields.email')),
            ])->columnSpan(3)
        ];
    }
}```
icaliman commented 6 months ago

I have the same issue.

One solution is to replace the Livewire components after panel boot:

use Jeffgreco13\FilamentBreezy\BreezyCore;
use App\Http\Livewire\CustomPersonalInfo;

class CustomersPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ...
            ->plugin(
                BreezyCore::make()
                    ->myProfile()
                    ->myProfileComponents([
                        'personal_info' => CustomPersonalInfo::class,
                    ])
            )
            ->bootUsing(function () {
                Livewire::component('personal_info', CustomPersonalInfo::class);
            })
    }
}