FilamentF
Filament3y ago
Veur

CreateOptionForm is not showing

I have a working form that contains a select field to set a user's city_id. I'm trying to add a createOptionForm, but the modal won't show up (but there is network activity, see video).

This is the code of the form:

protected function form(Form $form): Form
    {
        return $form
            ->schema([
                Select::make('city_id')
                    ->label('Select city')
                    ->relationship('city', 'name')
                    ->preload()
                    ->required()
                    ->createOptionForm([
                        TextInput::make('name')
                            ->label('City')
                            ->required(),
                    ]),
            ])
            ->model($this->user);
    }


And the relationship in the User model:

    public function city()
    {
        return $this->belongsTo(City::class)
            ->withDefault([
                'name' => 'Unknown',
            ]);
    }
Was this page helpful?