如何在Laravel中将多个变量从视图传递到控制器? [关闭]

问题描述:

I want to pass form data from the view to the function inside a controller. What are the ways to do it?

我想将视图中的表单数据传递给控制器​​内的函数。 有什么方法可以做到? p> div>

Simply this:

In View:

{ Form::open(array('action' => 'Controller@method')) }}
    {{ Form::text('rate', '', array('placeholder' => 'Enter new custom client rate...')) }}
    {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}

In your Controller:

class Controller extends BaseController {
   public function method()
   {
       // get the rate value
       $rate = Input::get('rate');

       or

       // to get all form values
       $allFormValues = Input::all();

   }
}

And that's it.

Laravel is smart enough to get all of those request values.