F
Filament4mo ago
Neamix

Add submit button to filament form in custom page

I have custom page called chat inside it i added filament form
{
use InteractsWithForms;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.chatroom-page';
protected static ?string $slug = 'room/{id}';
protected static string $label = '';
protected static ?string $title = '';
protected static ?int $id = null;
protected static $reservation = 12;
protected $data = [];

public static function shouldRegisterNavigation(): bool
{
return false;
}

public function mount()
{
$chatroom = Chatroom::find(request()->id);
self::$reservation = $chatroom->reservation;
}

public function form(Form $form): Form
{
return $form
->schema([
RichEditor::make('content')
->label('')
->required()
]);
}
}
{
use InteractsWithForms;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.chatroom-page';
protected static ?string $slug = 'room/{id}';
protected static string $label = '';
protected static ?string $title = '';
protected static ?int $id = null;
protected static $reservation = 12;
protected $data = [];

public static function shouldRegisterNavigation(): bool
{
return false;
}

public function mount()
{
$chatroom = Chatroom::find(request()->id);
self::$reservation = $chatroom->reservation;
}

public function form(Form $form): Form
{
return $form
->schema([
RichEditor::make('content')
->label('')
->required()
]);
}
}
the blade
<x-filament-panels::page>

<div class="form">
<form wire:submit.prevent="submitForm">
{{ $this->form }}

<x-filament::button type="submit" class="mt-6">
Send comment
</x-filament::button>
</form>
</div>
</x-filament-panels::page>
<x-filament-panels::page>

<div class="form">
<form wire:submit.prevent="submitForm">
{{ $this->form }}

<x-filament::button type="submit" class="mt-6">
Send comment
</x-filament::button>
</form>
</div>
</x-filament-panels::page>
i want to add submit button to the form where on click the form will validate then insert it to message table, i tried to search in filament form docs but i cant find any clue
1 Reply
Want results from more Discord servers?
Add your server