© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
21 replies
Dhaval Kacha

How to add only edit form to a livewire component.

Hey there!
I'm trying to build filament form inside livewire component but I want only edit form, when user click on edit action it should open edit form with data prefilled.
I've tried installing it from documentation, but somehow its not working.
Right now on click of edit button it's not opening any model, also the form field 'Reason' and submit button showing like attaching in screenshot.
Is there anything I'm doing wrong.
class BookedSlots extends Component implements HasTable, HasForms
{
    use InteractsWithTable, InteractsWithForms;
    public ?array $data = [];
    public function mount()
    {
        $this->form->fill(Slot::with('event')->get()->toArray());
    }
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('reason'),
            ])
            ->statePath('data')
            ->model(Slot::class);
    }
    public function create(): void
    {
        $data = $this->form->getState();
        dd($data);
        $this->record->update($data);
    }
    public function table(Table $table): Table
    {
        return $table
            ->query(Slot::with('event')->where('user_id', Auth::id()))
            ->columns([
                TextColumn::make('event.name')->searchable()->sortable()->label('Event Name')
            ])
            ->actions([
                EditAction::make(),
            ]);
     }
class BookedSlots extends Component implements HasTable, HasForms
{
    use InteractsWithTable, InteractsWithForms;
    public ?array $data = [];
    public function mount()
    {
        $this->form->fill(Slot::with('event')->get()->toArray());
    }
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('reason'),
            ])
            ->statePath('data')
            ->model(Slot::class);
    }
    public function create(): void
    {
        $data = $this->form->getState();
        dd($data);
        $this->record->update($data);
    }
    public function table(Table $table): Table
    {
        return $table
            ->query(Slot::with('event')->where('user_id', Auth::id()))
            ->columns([
                TextColumn::make('event.name')->searchable()->sortable()->label('Event Name')
            ])
            ->actions([
                EditAction::make(),
            ]);
     }

blade component code.
<div class="p-6 text-gray-900 dark:text-gray-100">
    <form wire:submit="create">
        {{ $this->form }}

        <button type="submit">
            Submit
        </button>
    </form>
    <x-filament-actions::modals />
    {{ $this->table }}
 </div>
     
<div class="p-6 text-gray-900 dark:text-gray-100">
    <form wire:submit="create">
        {{ $this->form }}

        <button type="submit">
            Submit
        </button>
    </form>
    <x-filament-actions::modals />
    {{ $this->table }}
 </div>
     

Thanks!
image.png
Solution
https://filamentphp.com/docs/3.x/forms/advanced#saving-data-to-relationships
Advanced forms - Form Builder - Filament
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Add filament form in Livewire component
FilamentFFilament / ❓┊help
2y ago
How to trigger a Livewire component update after saving an Edit form?
FilamentFFilament / ❓┊help
2y ago
Adding a form to a Livewire component
FilamentFFilament / ❓┊help
12mo ago
Adding a form to a Livewire component
FilamentFFilament / ❓┊help
2y ago