【问题标题】:laravel form keep redirecting to same pagelaravel 表单不断重定向到同一页面
【发布时间】:2019-06-12 14:55:13
【问题描述】:

我的表单有什么问题,它不断重定向到同一页面,并且在 url 中有令牌,知道为什么会发生这种情况

  <form action="{{url('variant')}}" method="POST">
                          @csrf

                          <div class="required field">
                    <div class="ui dropdown ui selection dropdown" style="max-width: 300px; margin-right: 17px;">
                          <i class="dropdown icon"></i>
                          <div class="default text">Soluation Body</div>
                          <div class="menu">
                          <div class="item" data-value="male">File Upload <span style="color: gray;">( zip )</span></div>
                          <div class="item" data-value="female">repository <span style="color: gray;">( github , gitlap ,...)</span></div>
                          <div class="item" data-value="female">List <span style="color: gray;">( futuers , basics )</span></div>
                          <div class="item" data-value="female">Code Editor <span style="color: gray;">( Code )</span></div>
                          <div class="item" data-value="male">Image <span style="color: gray;">( analysis || flow chart )</span></div>
                          </div>
                    </div>
                    <button  type="submit" class="ui button">Add</button>
              </div>
              </form>

我的路线

     Route::post('variant', 'v1\AnswerController@variants')->name('variant.add');

我的控制器

public function variants(Request $request)
{
    dd('No file');
}

【问题讨论】:

  • 这个url命中的地方,也发送方法代码
  • @BimalPrasadPandey 我已经更新了我的路线
  • 也发送变体方法
  • @BimalPrasadPandey 好的,我更新了,请检查
  • 在文件routes/web.php的开头尝试dd()。看看什么返回 request() 辅助函数

标签: laravel forms laravel-5 eloquent


【解决方案1】:

尝试将表单操作更改为使用路由:

<form action="{{ route('variant.add') }}">

【讨论】:

  • 您确定您的路线正确到达您的控制器吗?是在App\Http\Controllers\v1\AnswerController的文件结构中吗?
  • 如果不是会得到未定义的路由
猜你喜欢
  • 2018-08-18
  • 1970-01-01
  • 1970-01-01
  • 2020-04-26
  • 2016-02-27
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多