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.
you can call validate() method directly on Request object like so: $data = $request->validate([ "name" => "required|array|min:3", "name. *" => "required|string|distinct|min:3", ]); Hope it helps!!
Laravel's Illuminate\Http\Request class provides an object-oriented way to interact with the current HTTP request being handled by your application as well as retrieve the input, cookies, and files that were submitted with the request.
Laravel routes are located in the app/Http/routes. For instance, to pass in a name parameter to a route, it would look like this. Route::get('/params/{name}', function ($name) { return $name }); By convention, the Controller function accepts parameters based on the parameters provided.
The input values can be easily retrieved in Laravel. No matter what method was used “get” or “post”, the Laravel method will retrieve input values for both the methods the same way. There are two ways we can retrieve the input values. Using the input () method. Using the properties of Request instance.
HTML doesn’t provide a limit on the number of array elements that you can submit in a form, so if we had to validate each individually, it would be a headache. Luckily, Laravel provides a simple way to validate arrays and nested array input with the use of dot notation and the * character.
There’s equally validation for each value in the array, if the value is not null, it should be a valid phone number. P.S., my project uses the Laravel Collective package.
The name of the input file is an array. It's work fine if I want to get value of the input file just the normal name. The value return is empty. What I want is to get value from input file as array.
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With