request value of a checkbox in Laravel

Asked

Viewed 3,340 times

0

I need to get the value of this checkbox but nothing is working.

@foreach ($options->getGenresEventos() as $agenda)
 <input type="checkbox" name="cat" id="cat" class="checkbox" value="{{strtolower($agenda)}}" data-bind="checked: params.genres"/> {{ $agenda }}<br><br>
@endforeach

did so

<input type="hidden" name="city" value="@if(Input::get('genre')){{Input::get('genre')}} @else {{Request::('cat')}} @endif" />

I appreciate any help

1 answer

1

Just set the checkbox in HTML.

So with pure HTML

<input type="checkbox" name="status" value="1">

and so with the Lockable

{!! Form::checkbox('status') !!}

If the checkbox is not selected it will not send to the controller via the request. then you can check in the controller this way:

$dataForm = $request->all();

$dataForm['status'] = (!isset($dataForm['status']))? 0 : 1;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.