FilamentF
Filament10mo ago
Arjen

Form with Wizard not saving relations with non-default statePaths

I've got the following code:
class PlaceServiceForm extends Component implements HasForms
{
    use InteractsWithForms;

    public ?array $data = [];

    public function mount(): void
    {
        $this->form->fill();
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Wizard::make([
                    Forms\Components\Wizard\Step::make('Aanbod plaatsen')
                        ->schema([
                            // ...
                            Forms\Components\CheckboxList::make('categories')
                                ->label('Categorieën (max. 3)')
                                ->relationship(
                                    titleAttribute: 'name',
                                ),
                            // ...
                        ])
                        ->statePath('data.service')
                        ->model(Models\Service::class),
                    Forms\Components\Wizard\Step::make('Organisatiegegevens')
                        ->schema(OrganizationRegistration::getFormSchema())
                        ->statePath('data.organization')
                        ->model(Models\Organization::class),
                    Forms\Components\Wizard\Step::make('Logingegevens')
                        ->schema(UserRegistration::getFormSchema())
                        ->statePath('data.user')
                        ->model(Models\User::class),
                ])
                    ->submitAction(new HtmlString(Blade::render(<<<'BLADE'
                <x-filament::button type="submit">
                    Plaatsen
                </x-filament::button>
            BLADE))),
            ])
            ->statePath('data');
    }
Was this page helpful?