Reputation: 21
I'm trying to return the value of a checkbox within my laravel controller, but every time I request a input from a checkbox element in a form, it returns null.
My controller, retrieving the input of a element called Filter-Method.
Here I'm trying to request a input method called filter-method which is a checkbox.
My Route, since this function will execute on a button:
My Blade, where I'm trying to retrieve the result of my filter-method checkbox:
On line 38 I have a checkbox called filter-method, and when you click on the button on line 115 it should send a request to the controller where it would return a result but instead it returns null
Any ideas of why I'm returning null?
Upvotes: 1
Views: 6607
Reputation: 2708
This is very basic thing just use form instead of <a>
tag. Every time you need to send input value to server you need to use <form>
element. In image you have uploaded there is no <form>
and you are using a <a>
tag.
You need to do it like this
<form method="get" action="/getFilterBycolumns">
<input type="checkbox" name="filter-method">
// other input fields
// and then a submit button instead of <a>
<button class="your-class" type="submit"> Send</button>
Upvotes: 0
Reputation: 1786
You have to add form to your blade around checkbox either with get or post method as per your requirement change route according to your form method
consider demo blade file
<form method="get" action="{{ url('GetFilterByColumns') }}" class="form-horizontal form-label-left" id="">
<div class="checkbox">
<label><input type="checkbox" name="filter-method" value="filter-method>Method</label>
</div>
<input type="submit" value="submit"/>
</form>
Now you will get a checkbox value in contoller
Upvotes: 0
Reputation: 415
You are not passing any parameter named filter-method. If you are posting values you should use post method.
Like following
Route::post('GetFilterByColumns','MentorController@FilterByValuesColoumns')
If you want to list data according to filter-method then try the following.
Route::get('GetFilterByColumns/{filter-method}','MentorController@FilterByValuesColoumns')
And in your mentorlist.blade.php page
change the href value according to route.
Upvotes: 2