Support the ongoing development of Laravel.io →
Input Database Forms
Last updated 2 years ago.
0

You can use:

Input::has('secure') like that:

If (Input::has('secure')){ $secure = 1; (Checkbox is checked) }else{

$secure = 0; (Checkbox is not checked) }

Last updated 2 years ago.
0

If I save the form with the checkbox ticked it saves as a 1 in the database and if I save the form with the checkbox not ticked the it saves as a NULL instead of a 0.

And I added

"secure" => Input::get("secure")

to

if($form->isValidForAdd()){
					Resource::create([
						"name" => Input::get("name"),
						"pattern" => Input::get("pattern"),
						"target" => Input::get("target"),
						"secure" => Input::get("secure")
					]);

and I changed

{{ Form::checkbox('secure', 'yes') }}

to

{{ Form::checkbox('secure', 1, true) }}
Last updated 2 years ago.
0
Solution

I solved this by changing

"secure" => Input::get("secure")

to

"secure" => (Input::has("secure")) ? true : false

and changing

{{ Form::checkbox('secure', 1, true) }}

to

{{ Form::checkbox('secure[]', 0, false) }}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.