【问题标题】:laravel 4 form open and route not definedlaravel 4 表单打开且路由未定义
【发布时间】:2014-01-12 07:40:01
【问题描述】:

我在 {{ Form::open() }} 中的操作有问题

路由 [adm/tagedit] 未定义。

我的代码是

 {{ Form::open(['method'=>'post','action'=>"adm/tagedit"])}}
        {{ Form::submit('edit',['class'=>'btn btn-default']) }}
        {{ Form::close() }}

在路线中

Route::get('adm/{action?}/{params?}',function($action,$params=null){
if(Auth::check()==false||Auth::user()->isAdmin()==false){
    return \Illuminate\Support\Facades\Redirect::to('/')->withError('Youe need be logged in');
}
return  (new AdmController())->{$action}($params);

});

//routing for bacend post method
Route::post('adm/{action?}/{params?}',['before'=>'csrf',function($action,$params=null){
    if(Auth::check()==false||Auth::user()->isAdmin()==false){
        return \Illuminate\Support\Facades\Redirect::to('/')->withError('You need be logged in');
    }
    return  (new AdmController())->{$action.'Post'}($params);
}]);

当然,如果我使用获取请求操作工作。在控制器中,我使用动作“tageditPost”

可能我的问题与 Rediredt 类似:route() 也不起作用。但是在重定向中,我使用 Reditect:to() 并且工作正常。在形式上,我不知道我应该改变什么。

提前感谢您的回答。

问候

【问题讨论】:

    标签: php laravel laravel-4


    【解决方案1】:

    尝试以下方法:

     {{ Form::open(['method'=>'post','url'=>"adm/tagedit"]) }}
         {{ Form::submit('edit',['class'=>'btn btn-default']) }}
     {{ Form::close() }}
    

    【讨论】:

    • 谢谢它的工作请告诉我,如果可能的话,在正则表达式路由的表单中使用 Redirect:route 痤疮动作?或者只有固定路线才有可能
    • 仅在表单中固定路由/URL/控制器操作。
    • 感谢您的快速答复。问候贾雷克
    猜你喜欢
    • 2019-09-10
    • 2015-01-07
    • 2013-09-19
    • 1970-01-01
    • 2013-09-22
    • 2018-06-30
    • 2018-12-16
    • 2014-09-20
    相关资源
    最近更新 更多