laravel 4表单打开,路由未定义

时间:2014-01-12 07:40:02

标签: php laravel laravel-4

我在{{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);
}]);

当然,如果我使用get request动作。在控制器中我使用动作" tageditPost"

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

提前感谢您的回答。

此致

1 个答案:

答案 0 :(得分:2)

尝试以下方法:

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