【问题标题】:using Bootstrap3 form in laravel5.1在 laravel 5.1 中使用 Bootstrap 3 形式
【发布时间】:2015-12-20 03:32:08
【问题描述】:

我正在尝试在 laravel5.1 中使用 bootstrap3 制作一个表单,以便我可以从用户那里获取值并将其存储在数据库中并希望重定向同一页面。 这是我的代码的表单部分--

<div class="row">
        <form action="{{url('fastshops/menu')}} " method="post" role="form">
            <legend>ADD NEW ITEM</legend>

            <div class="form-group">
                <label for=""></label>
                <input type="text" class="form-control" name="ItemID" id="" placeholder="Item ID...">
                <label for=""></label>
                <input type="text" class="form-control" name="ItemName" id="" placeholder="Item Name...">
                <label for=""></label>
                <input type="text" class="form-control" name="SellPrice" id="" placeholder="Sell Price...">
                <label for=""></label>
                <input type="text" class="form-control" name="NetPrice" id="" placeholder="Net Price...">

            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>

但这部分action="{{url('fastshops/menu')}} 不工作!如果我单击提交按钮,我会遇到 TokenMismatchException !请帮帮我。 提前致谢。

【问题讨论】:

    标签: twitter-bootstrap-3 laravel-5.1


    【解决方案1】:

    添加这个 &lt;input type="hidden" name="_token" value="{{Session::token()}}"/&gt;&lt;input type="hidden" name="_token" value="{{csrf_token()}}"/&gt; 在你的表格里面。 Laravel 5 自动检查所有路由的所有 Post 请求的 CSRF。阅读文档,它们非常自我解释

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-07
      • 2017-08-15
      • 2014-02-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多