简体   繁体   English

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

[英]laravel 4 form open and route not defined

I have problem with action in {{ Form::open() }} 我在{{Form :: open()}}中的操作有问题

Route [adm/tagedit] not defined. 路线[adm / tagedit]未定义。

My code in view is 我的代码是

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

and in routes 在路线上

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

Of course if I use get request action work. 当然,如果我使用get request动作。 In controller I use action "tageditPost" 在控制器中我使用动作“tageditPost”

Probably my problem is similar to Rediredt:route() is not work too. 可能我的问题类似于Rediredt:route()也不起作用。 But in redirect I use Reditect:to() and work fine. 但是在重定向中我使用Reditect:to()并且工作正常。 In form, I don't know what should I change. 在形式上,我不知道应该改变什么。

Thanks in advance for answers. 提前感谢您的回答。

Regards 问候

Try the following: 请尝试以下方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM