php artisan make:filament-page InformalRaportExport --type=custom
pada bagian php nya kira2 sperti ini. jangan lupa implement HasForms dan use InteractsWithForm. ini kondisi ketika menginginkan form di build pake filament
<?php
namespace App\Filament\Pages;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Forms\Components\Select;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Notifications\Notification;
class InformalRaportExport extends Page implements HasForms
{
use InteractsWithForms;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.informal-raport-export';
public $data = [];
public $name;
public $class;
public $date;
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Name')
->required(),
Select::make('class')
->label('Class')
->options([
'A' => 'Class A',
'B' => 'Class B',
'C' => 'Class C',
])
->required(),
DatePicker::make('date')
->label('Export Date')
->required(),
];
}
public function submit(): void
{
$data = $this->form->getState();
// Contoh: Menyimpan ke database
// \App\Models\Raport::create($data);
// Tampilkan notifikasi
Notification::make()
->success()
->title('Success')
->body('Data saved successfully.')
->send();
// Reset form
$this->form->fill([]);
}
}
dan pada blade kira kira seperti berikut
<x-filament::page>
<form wire:submit.prevent="submit" class="space-y-6">
{{ $this->form }}
<x-filament::button type="submit">
Submit
</x-filament::button>
</form>
</x-filament::page>
Namun jika mengingikan form di build pake livewire bisa sperti ini
pada blade nya. dan pada php component nya tidak usah di apa2kan
<x-filament-panels::page>
{{-- <livewire:counter/> --}}
<livewire:export-student/>
</x-filament-panels::page>
Jadi next nya tinggal buat component livewire nya
0 Komentar