【发布时间】:2016-02-26 22:27:46
【问题描述】:
我正在使用 cakePHP 创建 HTML 复选框,例如:
<?php echo $this->Form->checkbox('medicine_time.0', array('value' => 'morning', 'div' => false, 'label' => false)); ?> Morning
<?php echo $this->Form->checkbox('medicine_time.1', array('value' => 'noon', 'div' => false, 'label' => false)); ?> Afternoon
<?php echo $this->Form->checkbox('medicine_time.2', array('value' => 'eve', 'div' => false, 'label' => false)); ?> Evening
<?php echo $this->Form->checkbox('medicine_time.3', array('value' => 'night', 'div' => false, 'label' => false)); ?> Night
同时,我有一个数组,它的值将决定 checkbox 是 选中 还是 不
数组:
[medicine_time] => Array
(
[0] => morning
[1] => noon
[2] => 0
[3] => night
)
现在,如果我有 morning,我的第一个 same value 复选框应该被选中,依此类推。 或者,如果我将相同的数组修改为:
[medicine_time] => Array
(
[0] => morning
[1] => noon
[2] => night
)
会有帮助吗?
我怎样才能实现它?还是有其他方法?
【问题讨论】: