Why boolean parameters with the 'false' value, not received in request?
Hi,
Assume I received two parameter with bool1 and bool2 that are boolean and bool1 has been initialized with true and bool2 with false
Now this is my log:
Array
(
[bool1] => 1
[bool2] =>
)
bool2 not initialized with any value, but why?
Unchecked checkboxes are not sent.
<?php
echo true;
echo false;
When you open this in browser, the output will be
1
Which has been discussed many times here and it's basic HTML.
You yourself have to set up the logic to determine if nothing was passed.
<input type="hidden" name="something" value="0" />
<input type="checkbox" name="something" value="1" />
when checked it overrides the hidden value.
or just
<input type="checkbox" name="something" value="1" />
and
$value = (int)$request->has('something');
$value will be 1 if the checkbox was checked, or 0 if it wasn't.
Please or to participate in this conversation.