I want to get the id of the selected value or item from a dropdown selectbox because I want to save it in the database. So , I tried passing the it as a value to get it with an hidden field on the page but it does work. How do I do this? Thanks in advance. Appreciate. This is the form page:
<p>{!! Form::select('companyname', array('' => 'Select a Company') + $listCompanies) !!} </p>
@foreach($istCompaniesId as $company)
@if(companyname->text === $listCompaniesId->value)
{!! Form::hidden('company_id', $listCompaniesId->value) !!}
@endif
@endforeach
This is the controller:
$listCompanies = Company::where('user_id', '=', Auth::user()->id)->orderBy('companyname', 'desc')->lists('companyname', 'companyname')->toArray();
$listCompaniesId = Company::where('user_id', '=', Auth::user()->id)->orderBy('companyname', 'desc')->lists('companyname', 'id')->toArray();
return view('product.create')
->with('listCompanies', $listCompanies)
->with('listCompaniesId', $listCompaniesId);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire