当我在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>
正如你所看到的,cake在标签上重复了表单名称"test"。我该怎么解决这个问题?我尝试使用文件的确切代码,但仍然有相同的问题
希望你能帮我,谢谢
我会自动回答我的问题。这是cakepp的一个错误,在上一个版本中解决了:https://github.com/cakephp/cakephp/releases/tag/2.4.2
尝试使用
'label' => array(
'class' => 'thingy',
'text' => 'The User Alias'
)