FilamentF
Filament17mo ago
Sayy

how to custom actions on create record

how custom actions if the actions on create record, because im confuse after click the button actions then can generate pdf or something update data from im input on view create ?

 protected function getFormActions(): array
    {
        return [
            Actions\CreateAction::make()->label('Simpan & Cetak')
                ->color('warning')
                ->using(function (array $data): Model {
                    return static::getModel()::create($data);
                })->action(function (Order $record) {
                    $pdf = Pdf::loadView('pdf.print-order', [
                        'order' => $record,
                    ]);

                    return response()->streamDownload(function () use ($pdf) {
                        echo $pdf->stream();
                    }, 'receipt-' . $record->order_number . '.pdf');
                })->submit('form')
                ->button(),
            ...parent::getFormActions(),
        ];
    }
image.png
Solution
probably your repeater has a relationship.. if you want to access the repeater data in $data, you need to add ->dehydrated() in the repeater
Was this page helpful?