【发布时间】:2013-12-04 21:54:49
【问题描述】:
当我在 CakePHP 上使用单选输入创建表单时,生成的标签与单选输入的 id 不匹配,标签“for”与表单名称重复。这是我的代码:
echo $this->Form->create(
'test',
array(
'action' => 'index',
'type' => 'post',
'class' => 'fill-up',
'inputDefaults' => array('div' => 'input')));
$options = array('option1' => '1',
'option2' => '2');
$attributes = array('legend' = > false);
echo $this->Form->radio('Type', $options, $attributes);
echo $this->Form->end(
array(
'label' = > 'end',
'class' = > 'button',
'div' = > false));
生成的 HTML 类似于:
<input type="hidden" name="data[test][options]" id="testOptions_" value="">
<input type="radio" name="data[test][options]" id="TestOptionsOption1" value="option1">
<label for="testTestOptionsOption1">1</label>
<input type="radio" name="data[test][options]" id="TestOptionsOption2" value="option2">
<label for="testTestOptionsOption2">2</label>
如您所见,蛋糕在标签上重复了表单名称“test”。我该如何解决这个问题?我尝试使用文档的确切代码,但仍然遇到同样的问题
希望你能帮助我,非常感谢
【问题讨论】:
标签: php html cakephp radio-button