Ok, in CakePHP, I have the following code in my view add.ctp
:
echo $this->Form->radio('color', array('1' => 'red', '2' => 'green', '3' => 'blue'), array('value' => false));
which results in the correct html:
<fieldset>
<legend>Color</legend>
<input type="radio" name="data[Some][color]" id="SomeColor1" value="1" />
<label for="SomeColor1">red</label>
<input type="radio" name="data[Some][color]" id="SomeColor2" value="2" />
<label for="SomeColor2">green</label>
<input type="radio" name="data[Some][color]" id="SomeColor3" value="3" />
<label for="SomeColor3">blue</label>
</fieldset>
If I check "green" for example, a debug($this->data);
produces the expected result:
Array
(
[Some] => Array
(
[color] => 2
)
)
However, CakePHP inserts the wrong data in the table:
INSERT INTO `somes` (`color`) VALUES (1)
Any clue what's going on here? What am I missing?
EDIT:
- I am using
$this->Some->save($this->data)
and the datatype of color isTINYINT(1) UNSIGNED NOT NULL DEFAULT 0
. - For the sake of the example I removed the other data, but basically, everything else works just fine and the record is saved.