使用一个post请求在一个视图中使用两个或多个表单


two or more forms in one view using one post request

目前在我的视图中只有两个表单,它们都是post方法,我试图像这样解决

路线
Route::post('view', function(){
    if(Input::has('form1')){
        'NameController@method1';
    } elseif (Input::has('form2')){
       'NameController@method2';
    }
});
视图

{!! Form::open(array('url' => '/view')) !!}
    {!! Form::text('text', $trans->text)    !!}
    {!! Form::submit('Submit', array('name' => 'form1' )) !!}
{!! Form::close() !!}

{!! Form::open(array('url' => '/view')) !!}
    {!! Form::text('text', 'text')    !!}
    {!! Form::submit('Submit', array('name' => 'form2')) !!}
{!! Form::close() !!}

它会抛出这个错误

syntax error, unexpected ''ConfigurationController@title'    (T_CONSTANT_ENCAPSED_STRING) 

这是编码错误,我纠正了它,但它不会做我希望它只是返回空白屏幕它不循环通过控制器

我修改了代码(删除返回并关闭路由)

你要做的是在NameController和那里创建一个方法someMethodName

public function someMethodName()
{
    if(Input::has('form1')){
        $this->method1();
    } elseif (Input::has('form2')){
        $this->method2();
    }
}

然后用

替换所有route的内容
Route::post('view', 'NameController@someMethodName')