Answer the question
In order to leave comments, you need to log in
Why is the variable not being passed to the controller from the form?
The variable is not passed from the form to the controller. dd() shows that the variable is not receiving anything.
Template code:
<form action="{{ route('setTopic'}}" method="post" enctype="multipart/form-data">
@csrf
<div class="select-box">
<label for="select-box1" class="label select-box1"><span class="label-desc">Choose topic</span></label><button type="submit" class="btn btn-outline-success">Save</button>
<select id="select-box1" class="select" name="selectSetTopic">
@foreach($dataCategories as $topic)
<option value="{{$topic->id}}">{{ $topic->name }}</option>
@endforeach
</select>
</div>
</form>
public function setTopic(Request $selectSetTopic) {
dd($selectSetTopic);
return redirect()->route('post')->with('success', 'Ok!');
}
Answer the question
In order to leave comments, you need to log in
Why name variables like that? Why not leave the default name. Moreover, it accurately displays the entity (I'm talking about $request).
public function setTopic(Request $request) {
$selectSetTopic = $request->input('selectSetTopic');
dd($selectSetTopic);
return redirect()->route('post')->with('success', 'Ok!');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question