Conditional createOptionForm in Filament

What I did:
Select::make('user_id')
->label('Team Owner')
->visibleOn('create')
->createOptionForm([
TextInput::make('name')
->string()
->required()
->maxLength(255),
]),
Select::make('user_id')
->label('Team Owner')
->visibleOn('edit')
Select::make('user_id')
->label('Team Owner')
->visibleOn('create')
->createOptionForm([
TextInput::make('name')
->string()
->required()
->maxLength(255),
]),
Select::make('user_id')
->label('Team Owner')
->visibleOn('edit')
Is there a method in Filament that can help with this? Inside the TeamResource form, I created two select fields—one shows on create, and the other on edit. Is there a simpler way to show the createOptionForm only when creating?
1 Reply
Dennis Koch
Dennis Koch2w ago
This could work:
->createOptionForm(fn ($operation) => $operation == 'edit' ? [] : [your form])
->createOptionForm(fn ($operation) => $operation == 'edit' ? [] : [your form])

Did you find this page helpful?