i'm trying to execute some code using the October's Data Attribute API for front-end forms. The onSend function executes simple codes like echo 'something', but doesn't more complex code, like trying to use mpdf plugin. I guess it's related to AJAX reloading the page, but don't know how to solve it.
I tried using data-request from the Data Attribute API, calling the function onSend, but the code on onSend does not execute.
My form header is as follows:
<form class="register-form" method="POST" data-request="onSave">
and my function onSave:
public function onSave(){
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<div style="text-align: center"> Test </div>');
$mpdf->Output();
}
Note that both codes are on a component, and the onSave function executes when i try something just like:
echo 'Test';
答案 0 :(得分:1)
您要渲染/流式传输PDF?您是否在浏览器中查看了网络监视器?
我将通过public function onRun()
调用来测试您的mpdf代码。确保可以使用。
尝试更新部分内容。 data-request-update="'{{__SELF__::partial}}', '#element'"
除此之外,您可能需要执行整页重定向。我如何流式传输PDF是我有一个使用该https.domain.com/stream/pdf?id=encryptedsomething
的route.php。对该路径进行了编程,以在解密id
之后在模型中查找特定对象,并将数据显示为PDF。