Laravel 5 getting input values that are arrays

28,597

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().

Share:
28,597
Tartar
Author by

Tartar

A software engineering student who is intrested in java technologies and mobile software development.

Updated on July 09, 2022

Comments

  • Tartar
    Tartar almost 2 years

    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.

  • Bogdan
    Bogdan about 9 years
    I just tested Request::input('representive.address_1'); and it works just fine. Try doing a dd(Input::all()); in your controller and see if you are actually getting the parameter value from the client.
  • Tartar
    Tartar about 9 years
    The value of that {!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!} field does not appear in dd(Input::all()); array when i return it, not sure why.
  • Bogdan
    Bogdan about 9 years
    Then it most likely has something to do with the form itself. Please post more code from your form. How are you submitting the form: synchronously or with an AJAX request?
  • Tartar
    Tartar about 9 years
    Ajax would be more complex as i am a L5 newbie. Rest of the form seems fine, which part of the form might be causing this problem do you think ?
  • Bogdan
    Bogdan about 9 years
    I can't really say without seeing the entire form code.
  • Tartar
    Tartar about 9 years