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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器