Problem with checbox in add/edit.php always stay "true"
Permalink
I want to create custom "checkbox" - for this example named "test" (boolean).
In db.xml:
In form.php (add/edit):
In view:
When the block is added "$test" var = 0. "THE PROBLEM" once i set the checkbox to be "true" (1) - it always! stay like this (even when i un-check "test". I also check the DB table in PHPmyAdmin) - what i missing?
In db.xml:
<field name="test" type="boolean"> <default value="0"/> </field>
In form.php (add/edit):
<div class="checkbox"> <label> <input type="checkbox" name="test" value="1" <?php if ($test == 1) { ?>checked<?php } ?> /> <?= t('test checkbox.') ?> </label> </div>
In view:
echo "i am test checkbox" . $test;
When the block is added "$test" var = 0. "THE PROBLEM" once i set the checkbox to be "true" (1) - it always! stay like this (even when i un-check "test". I also check the DB table in PHPmyAdmin) - what i missing?
Because if you do not check the checkbox nothing comes through in the POST so the value never gets reset to 0.