Vue-select, how-to get $request value in Laravel's controller?
See original GitHub issueHi everyone,
Need some help. I am using Laravel 5.4.
Currently I have a standard select dropdown from Laravel Collection as below.
<div class="col-xs-6 form-group{{ $errors->has('product') ? ' has-error' : '' }}">
<label class="control-label">Product</label>
{!! Form::select('product', $products, null, ['class' => 'form-control', 'placeholder' => 'Pick a product...']) !!}
@if ($errors->has('product'))
<span class="help-block">
<strong>{{ $errors->first('product') }}</strong>
</span>
@endif
</div>
In Laravel, I can get the request for the above using this
$request->product
But when I use your vue-select component
e.g.
<div class="row">
<div class="col-xs-4">
<v-select :options="products" :placeholder="placeholder"></v-select>
</div>
</div>
How can I get the $request value for this field in Laravel controller?
Plus how can I validate vue-select if no value is selected?
Any help? Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How can I get the value from v-select using a name attribute ...
I am currently using Vuetify for theming only within a laravel application and do not want to reach into using v-model. Is there...
Read more >Requests & Input - The PHP Framework For Web Artisans
Getting Only Some Of The Request Input. $input = Input::only('username', 'password');. $input = Input::except('credit_card');.
Read more >Vue Select get request help - Laracasts
Hi. Im doing my first ajax request that queries the database to retrieve a list of items to use in a dropdown select...
Read more >How can I populate data which is fetched from API into select ...
Coding example for the question How can I populate data which is fetched from API into select option in Laravel using VueJS and...
Read more >Vue-Multiselect | Vue Select Library
View on GitHubGetting started & examples ... npm install vue-multiselect --save ... div label.typo__label Single select multiselect( v-model="value", ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ericmachine88, if you’re not submitting your form via
ajax
, then you’ll have to use a hidden input.vue-select
doesn’t contain an actual form input, but you can easily sync the selected option to a hidden input.If you’re using
vue-validator
, you will want to validate the hidden input, notvue-select
. On the Laravel side of things, you can just validate theproduct
field as you normally would:@ericmachine88 didn’t realize vue-validator wasn’t going to have support for v2. I’m sure someone else will build it though if it’s not already out there.
If you get creative with it, there are other ways. I just put together this example that uses a hidden text input to add the required HTML5 attribute.