如何使用laravel预填充Html表单字段?

时间:2017-10-17 06:44:02

标签: php laravel laravel-5.2

我想预先填写我的html表单字段"参考"来自引用的url值是否为ref?= 1234如何使用laravel

<form method="post" accept-charset="utf-8" class="block" enctype="multipart/form-data" action="{{ route('register') }}">
                        {!! csrf_field() !!}
                        <div class="row">
                            <div class="col-md-12 col-sm-12">
                                <div style="width: 100%" class="alert alert-warning">
                                    Please Register With a Reference User.
                                </div>
                            </div>
                        </div>

                        <div class="input-group">
                            <input type="text" name="reference" value="HERE WANT TO SHOW REFEERENCE CODE FROM URL" required class="form-control" placeholder="Enter Reference ID *" aria-describedby="basic-addon1">
                            <span class="input-group-addon" id="basic-addon1"><i class="fa fa-handshake-o"></i></span>
                        </div>

4 个答案:

答案 0 :(得分:2)

您可以使用:

<input type="text" name="reference" value="{{ app('request')->input('ref') }}" required class="form-control" placeholder="Enter Reference ID *" aria-describedby="basic-addon1">

答案 1 :(得分:1)

试试这个。输入(&#39; ref&#39;)}}&#34;要求的等级=&#34;形式控制&#34;占位符=&#34;输入参考ID *&#34;咏叹调-describedby =&#34;碱性addon1&#34;&GT;

答案 2 :(得分:0)

PHP中没有$GET变量。

$_GET

在laravel中,您可以使用Request外观或Input外观

所以这里:

<input value="view{{ \Request::get('ref') }}" type="text" name="reference" required class="form-control" placeholder="Enter Reference ID *" aria-describedby="basic-addon1">

// http://localhost/codec/register?ref=g5M089zQeVzc
// will produce
// <input value="viewg5M089zQeVzc" ...

答案 3 :(得分:0)

使用request()帮助:

$ref = request('ref'); // It will return 1234.