F
Filament8mo 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);
}
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',
]);
}
public function city()
{
return $this->belongsTo(City::class)
->withDefault([
'name' => 'Unknown',
]);
}
4 Replies
Dennis Koch
Dennis Koch8mo ago
Is this a custom page? Anything special? Did you try with latest Filament version and ran artisan filament:upgrade?
Veur
Veur8mo ago
This is inside a Livewire component, not in a Filament Panel. I have Filament version 3.0.101 and ran php artisan filament:upgrade
toeknee
toeknee8mo ago
Anything in the console?
Veur
Veur8mo ago
Nothing in the console