Search code examples
htmllaravelhref

Pass data from class select to get route


how can I pass data from this form to my route?

<div class="panel-body">
    {!! Form::open(array('route'=>'show.exclusion')) !!}
        <div class="form-group">
            {{Form::label('choosegroup', 'Wähle eine Gruppe')}}
            <select class="form-control m-bot15" name="idgroup">
                @foreach($groups as $group)
                    <option value="{{ $group->id }}">{{ $group->name }}</option>
                @endforeach
            </select>
            {{ csrf_field() }}
        </div>
        <div>
            {{Form::submit('Search',['class' => 'btn btn-primary'])}}
            <a class="btn btn-default btn-close" href="{{ route('home') }}">Cancel</a>
        </div>
    {!! Form::close() !!}
</div>

This is my route...

Route::get('exclusion/show/{id}', 'ExclusionController@show')->name('show.exclusion');

First I put the $group->id parameter into the array route part. But I cannot use them at this point of my code.

Any Ideas?

EDIT:

public function show($id)
{  
    $member = Nerd::find($id);

    return view('groups.test')->with('member', $member);
}

Solution

  • You need to pass the whole Request to the function. Than it is possible to get the Values of your Formdata.

    public function update(Request $request, $id)
    {
            $idgroup = $request->input('idgroup');
    }
    

    For more details have a look here: https://laravel.com/docs/5.6/requests