douyu9433 2019-06-19 23:06
浏览 350

将输入值从一个页面发送到另一个页面

I'm working on Laravel project and I want to send my input values from the FORM from one page (the inscription page) to a pdf page (which I want the user to be able to download). I couldn't find a way to send them from that page to the other

input:all using the $request in the controller

<div class="fieldgroup">
                            <input type="text" style="color:0B0C51" onclick="submitform2()" name="cin" id="cin"
                                    placeholder="N°CIN" maxlength="8" class="required"></i><br>

                    </div>


                    <div class="fieldgroup">
                            <input type="text" style="color:0B0C51" v-model="prenom" name="prenom" id="prenom"
                                    placeholder="Prenom" class="required"><br>
                    </div>


                    <div class="fieldgroup">
                            <input type="text" style="color:0B0C51" v-model="nom" onclick="submitform2()" name="nom"
                                    id="nom" placeholder="Nom" class="required"><br>
                    </div>

                    <div class="fieldgroup">
                            <input type="mail" style="color:0B0C51" name="email" id="email" placeholder="Email"
                                    class="required" />

                    </div>

ViewController :

    class ViewController extends Controller
{

public function generatePDF(Request $request){
    $request=this.
    $data="form";
    $pdf= PDF::loadView('pdf',compact('data'));
    return $pdf->download('Terms.pdf');
}

}

web.php:

       Route::get('/pdf','ViewController@generatePDF');

inscriController:

public function store(Request $request)
{   
    $cin = $request->input('cin');
    $data = array(['cin'=>$cin ]);

    DB::table('form')->insert($data);

    return redirect('/pdf')->withInput();

This returns an empty form page without the input values

  • 写回答

2条回答 默认 最新

  • duanquyong8164 2019-06-19 23:30
    关注

    It may be easier to load the pdf right in the store method of inscriController. As it is, you are redirecting and passing no data into the pdf generator / view. You set $request as the controller ($this), which has none of the form data, and then you pass a single word 'form' as your data-set into the PDF generator. I don't think this will work the way you wish - I assume the pdf view is looking for specific variables (not 'form'), and thus it is failing because those vars are missing. IE you'd want to pull those vars like $name = $request->get('name') and pass whatever pdf.blade.php view needs from your $request var.

    If you don't want to do it all in the store function, perhaps pass it to a method in the same inscriController? This way you can easily push the actual request object into that method and pull the fields you need for the PDF view.

    评论

报告相同问题?

悬赏问题

  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现