5

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.

4
  • Shouldn't that be Request::get('representative'); and then take the values from that array? Commented Jun 14, 2015 at 16:47
  • Just do Request::get('representative.address_1');. The ".0" part is what shouldn't be there. Also you misspelled the variable as "$adress" by the way. Commented Jun 14, 2015 at 17:12
  • @orrd Request::get('representative.address_1'); does not work. I tried it already Commented Jun 14, 2015 at 17:47
  • Oh, sorry I actually what I should have said was Input::get('representative.address_1');. The Request::get() method doesn't understand dot notation because it's a Symfony method. Otherwise, Joel Hinz's answer would also work if you need to use Request::get() for some reason. Commented Jun 14, 2015 at 18:28

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

6 Comments

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.
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.
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?
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 ?
I can't really say without seeing the entire form code.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.