2013-11-20 42 views
0

當我使用無線電輸入在CakePHP上創建一個表單時,生成的標籤與收音機輸入的ID不匹配,標籤「for」複製表單的名稱。這裏是我的代碼:cakephp爲無線電輸入生成錯誤的標籤ID

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> 

,你可以看到,蛋糕複製窗體名稱「測試」的標籤。我如何解決這個問題?我嘗試用單證的確切的代碼,仍然有同樣的問題

希望你能幫助我,THX非常

回答

0

嘗試使用

'label' => array(
     'class' => 'thingy', 
     'text' => 'The User Alias' 
    ) 
+0

只添加了這個:'class =「thingy」text =「User Alias」到標籤中,但「for」是相同的' for =「testTestOptionsOption1」' – Davixe

相關問題