douzhu7507 2015-06-16 08:52
浏览 53

Laravel,提交GET表格不会触发路线

So i have a very strange problem occurring at the moment where i have a form that that submits as POST and triggers the route fine, whereas if the the form submits as GET it does not get triggered. It is just the strangest thing, in its simplified form the code looks like:

Works

route

route::post('/contributions/finalise', [ 'as' => 'contributions.finalise', 'uses' => function() {
    dd('i get output');
}]);

form

{!! Form::open(['route' => 'contributions.finalise', 'method' => 'POST']) !!}

    {!! Form::input('hidden','amount', null, ['id' => "contribute-amount"]) !!}

    <button type="submit">Submit</button>

{!! Form::close() !!}

Doesn't work

route

route::get('/contributions/finalise', [ 'as' => 'contributions.finalise', 'uses' => function() {
    dd('i DON'T get output, only a white screen is shown.');
}]);

form

{!! Form::open(['route' => 'contributions.finalise', 'method' => 'GET']) !!}

    {!! Form::input('hidden','amount', null, ['id' => "contribute-amount"]) !!}

    <button type="submit">Submit</button>

{!! Form::close() !!}

As you can see they are very similar but the GET just doesn't work? Am i missing something really basic here?

Thanks for your help

  • 写回答

2条回答 默认 最新

  • dph58509 2015-06-16 08:59
    关注

    What error show for your post request? I think this will be problem of CSRF Token. Add CSRF Token filed at your form.

    {!! Form::open(['route' => 'contributions.finalise', 'method' => 'POST']) !!}
        // Add CSRF Field
        {!! csrf_field() !!}
    
        {!! Form::input('hidden','amount', null, ['id' => "contribute-amount"]) !!}
    
        <button type="submit">Submit</button>
    {!! Form::close() !!}
    
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?