Filament Multi Tenant app CreateOptionForm

Hello,

I am developing my multi-tenant app and want to use quick add using createOptionForm.

This below is my create option forms.

Select::make('department_id')
  ->relationship('department', 'name', fn (Builder $query) => $query->whereBelongsTo(Filament::getTenant()))
  ->native(false)
  ->required()
  ->createOptionForm([
    TextInput::make('company_id')
      ->numeric()
      ->default(Filament::getTenant()->id),
    TextInput::make('name')
      ->label('Department Name')
      ->required()
      ->columnSpanFull(),
    ]),
  Select::make('title_id')
    ->relationship('title', 'name', fn (Builder $query) => $query->whereBelongsTo(Filament::getTenant()))
    ->native(false)
    ->required()
    ->createOptionForm([
      TextInput::make('company_id')
        ->numeric()
        ->default(Filament::getTenant()->id),
      TextInput::make('name')
        ->label('Title Name')
        ->required()
        ->columnSpanFull(),
    ]),


this works perfectly fine but I dont want to show the company_id field. When I also give property
->visible(false)


it throws me error that company_id constraint cannot be null.

Can you point me to the right direction?

Thanks a lot in advance
Solution
It was like the first line below. But in Laravel docs, it is like the second line "with brackets"

#[ObservedBy(TitleObserver::class)] 
#[ObservedBy([TitleObserver::class])]
Was this page helpful?