Search code examples
phplaravelinputlaravel-5laravel-form

Laravel 5 getting input values that are arrays


I have a text field like

{!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!}

In my form. And when I try to get its value in my controller but it comes null. What I try is

$adress = Request::get('representive.0.address_1');

I also tried some other ways but could not end up with a proper solution. How can I get the value of this field? Any help would be appreciated.


Solution

  • The Request::get() method is implemented by Symfony\Component\HttpFoundation\Request which the Illuminate\Http\Request class extends. This method does not parse the string parameter passed using the dot notation as Laravel does. You should instead be using the Request::input which does:

    $adress = Request::input('representive.address_1');
    

    As an alternative you can also use the Input facade and do Input::get().