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()
.
Author by
Tartar
A software engineering student who is intrested in java technologies and mobile software development.
Updated on July 09, 2022Comments
-
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 about 9 yearsI just tested
Request::input('representive.address_1');
and it works just fine. Try doing add(Input::all());
in your controller and see if you are actually getting the parameter value from the client. -
Tartar about 9 yearsThe value of that
{!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!}
field does not appear indd(Input::all());
array when i return it, not sure why. -
Bogdan about 9 yearsThen 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 about 9 yearsAjax 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 about 9 yearsI can't really say without seeing the entire form code.
-
Tartar about 9 yearsLet us continue this discussion in chat.