Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Why checkbox return ON instead 1

Hi, I have a "active" field in my database and I have a search form with this field, like this:

<?php echo $this->tag->checkField(["active", "class" => "form-control", "id" => "fieldActivo"]) ?>

In my controller I get this with:

$this->request->getPost("active")

When I check this in my controller I recived ON instead 1 and I do not know why. My type field in database is TINYINT(1) and I tried with INT(1) with the same result.

Any idea?

Thx!



123
Accepted
answer

Try

<?php echo $this->tag->checkField(["active", "class" => "form-control", "id" => "fieldActivo", "value" => 1]) ?>



1.1k

Try

<?php echo $this->tag->checkField(["active", "class" => "form-control", "id" => "fieldActivo", "value" => 1]) ?>

And I suppose TAG component handle checkbox with ON....

FYI - the "on" value isn't just with Phalcon - it's just what browsers send when a checkbox is checked.