有谁知道如何在 CakePHP 的表单中显示两个单选按钮并将它们保存到数据库中的布尔字段?
我可以让我的布尔值显示为复选框(默认行为),但我需要显示两个单选按钮,但是当我这样做时,更改不会保存到数据库中。
我觉得这是一件非常简单的事情。这是我的代码:
<h1>Edit Content</h1>
<?php
$thisVal = $this->data['LessonContent']['is_exercise'] ? "1" : "0";
$options = array(
    '0' => 'Learning Material',
    '1' => 'Exercise'
);
echo $this->Form->create('LessonContent', array('action'=>'edit'));
echo $this->Form->input('name', array('label' => 'Name'));
echo $this->Form->input('description', array('label' => 'Description'));
echo $this->Form->input('is_exercise', array(
    'type'      =>  'radio',
    'class'     =>  'radio',
    'legend'    =>  false,
    'name'      =>  'Type',
    'options'   =>  $options,
    'value'     =>  $thisVal
));
echo $this->Form->input('id', array('type'=>'hidden'));
echo $this->Form->input('lesson_id', array('type'=>'hidden'));
echo $this->Form->end('Save Content');
echo $this->Html->link('Cancel', array('controller'=>'Lessons', 'action'=>'view', $this->data['Lesson']['id']));
?>
谢谢