createOptionForm does not return the correct query

Hi, I am tying to create a createOptionForm. But for some reason it is ignoring all of the fields I defined. It just gives a basic create query:
INSERT INTO `relation_addresses` (`updated_at`, `created_at`) VALUES (2023-10-09 14:46:58, 2023-10-09 14:46:58)
INSERT INTO `relation_addresses` (`updated_at`, `created_at`) VALUES (2023-10-09 14:46:58, 2023-10-09 14:46:58)
This is my select input: (I removed some fields due to the Discord character limit.)
->createOptionForm(function (Get $get) {
return [
Forms\Components\TextInput::make('relation_id')->default($get('relation_id')),
Forms\Components\TextInput::make('name')->label('Naam')
->required()
->maxLength(255),
];

}
->createOptionForm(function (Get $get) {
return [
Forms\Components\TextInput::make('relation_id')->default($get('relation_id')),
Forms\Components\TextInput::make('name')->label('Naam')
->required()
->maxLength(255),
];

}
This is the parent select:
Forms\Components\Select::make('relation_address_id')->label('Kies een adres')
->relationship('relationAddress', 'name')
->disabled(fn (Forms\Get $get) => $get('relation_id') == null)
->required()
->options(function(callable $get) {
$relation = Relation::find($get('relation_id'));
if (!$relation) {
return [];
}
return $relation->addresses()->pluck('name', 'id');
})
->createOptionForm(__The code above__)
);
Forms\Components\Select::make('relation_address_id')->label('Kies een adres')
->relationship('relationAddress', 'name')
->disabled(fn (Forms\Get $get) => $get('relation_id') == null)
->required()
->options(function(callable $get) {
$relation = Relation::find($get('relation_id'));
if (!$relation) {
return [];
}
return $relation->addresses()->pluck('name', 'id');
})
->createOptionForm(__The code above__)
);
Does anyone know what I am doing wrong?
4 Replies
Luukd_2000
Luukd_200010mo ago
After some more testing this seems to also happen in a relationManager with this model. Does anyone know what I am doing wrong? I am using multi tenancy but that seems to work correctly
toeknee
toeknee10mo ago
Have you included the fields in the model fillables?
Luukd_2000
Luukd_200010mo ago
Thanks that was it. I always use the $guarded. But someone added $fillable. thanks for pointing me in that directio direction*
toeknee
toeknee10mo ago
No worries, if you are only using Filament for CRUD Tasks please re-visit the documentation where we advise dropping fillable off