© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Helge Sverre

Prefilling a Field in "Create New Option" Modal of a Select Component in FilamentPHP**

I want to prefill a field in the "create new option" modal, Here's the code I've tried, but it doesn't seem to be effective:

<?php

use App\Filament\Actions\CreateProductInPaddle;
use App\Filament\Resources\ProductResource;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;

Select::make('product_id')
    ->relationship('product', 'title')
    ->placeholder('No products available')
    ->searchable()
    ->createOptionForm(function (Form $form) {
        $form->fill(["title" => "prefilled"]);
        return ProductResource::form($form);
    })
    ->createOptionUsing(fn($data, CreateProductInPaddle $action) => $action($data))
    ->allowHtml()
    ->required(),
<?php

use App\Filament\Actions\CreateProductInPaddle;
use App\Filament\Resources\ProductResource;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;

Select::make('product_id')
    ->relationship('product', 'title')
    ->placeholder('No products available')
    ->searchable()
    ->createOptionForm(function (Form $form) {
        $form->fill(["title" => "prefilled"]);
        return ProductResource::form($form);
    })
    ->createOptionUsing(fn($data, CreateProductInPaddle $action) => $action($data))
    ->allowHtml()
    ->required(),

Is there a proper way to prefill data in this scenario with Filament, or is this not supported yet?
Any suggestions or code examples would be greatly appreciated.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Select field create new option in modal but using url of existing resource/create - Action in modal
FilamentFFilament / ❓┊help
3y ago
select field relationship create modal
FilamentFFilament / ❓┊help
3y ago
Modal image instead of select option
FilamentFFilament / ❓┊help
2y ago
Creatinga a new option in select
FilamentFFilament / ❓┊help
16mo ago