Skip to content
Advertisement

Laravel checkbox is not submitted to controller

I have a simple form in a view like this:

JavaScript

I used

JavaScript

for checking all of values posted to controller from view. the result is like below and I want to know how to post checkbox value with form.

array:4 [▼

“title” => “”

“type” => “”

“postfix” => “”

“_token” => “kSM3pO11KOOWQcCx4PeWcbi4r4AsFx0rSGQoVFtG”

]

Advertisement

Answer

A checkbox input is not submitted to the server side script if not checked by the user or by a client side script. So, in these cases, the input isn’t sent to your controller

In laravel, if you want to ‘normalize’ somehow the situation when the input isn’t sent, you can create a field by yourself:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement