I want to retrieve data from my form in controller, but instead of value it returns the index of it. My view:
{{ Form::open(['route' => 'videos.show']) }}
{!! Form::label('muscle', 'Choose a muscle') !!}
{!! Form::select('muscle', $select, ['class'=>'form-control']) !!}
{{ Form::submit('Filter') }}
{{Form::close()}}
My controller:
public function showVideos(Request $request){
$muscle = request()->input('muscle');
dd($muscle);
}
Form::select
expects an associative array containing key value pairs where the key is used for the select value and the value is used for text. Because you didn't add any keys, the default index is used for this array. If you want to receive the string in your postback, you will need to add these as the key in your array.
For example:
$select = [];
foreach ($subsubvideos as $subsubvideo)
{
if(!$subsubvideo->subSubCategories->isEmpty())
{
$select[$subsubvideo->category_name] = $subsubvideo->category_name;
}
}