I want to send an email to the customer after filling up the form, I tried to use BarryvdhDomPDF for that, I had two functions loadHtml and loadView,
I tried this way :
controller :
<?php
namespace AppHttpControllers;
use AppFilamentResourcesFormResource;
use AppFilamentResourcesFormResourcePagesViewForm;
use Illu4minateHttpRequest;
use BarryvdhDomPDFFacadePdf;
use IlluminateSupportFacadesStorage;
use IlluminateViewView;
class PdfController extends Controller
{
public static function generate($record, $resource)
{
$view = view('filament.pages.custom-view-page', [
'record' => $record,
'resource' => $resource
]);
$pdf = Pdf::loadView($view, []);
return $pdf->download('form.pdf');
}
}
View blade page (custom ViewPage) :
@class([
'fi-resource-view-record-page',
'fi-resource-' . str_replace('/', '-', $resource->getResource()::getSlug()),
'fi-resource-record-' . $record->getKey(),
])
>
<div
wire:key="{{ $resource->getId() }}.forms.{{ $resource->getFormStatePath() }}"
>
{{ $resource->form }}
</div>
</x-filament-panels::page>
I have got this error :
Using $this when not in object context
this is because of using $recource that represent $this in the original ViewPage in filament.
my question is : how to export the form to a pdf?
NourEddine GACHTOU is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.