2013-07-16 74 views
0

Cake 2.x中的單選按鈕有單獨的類選項嗎?單選按鈕的單個類選項

在我看來,合理的做法是這樣的:

<div class="input radio required"> 
    <?php 
     $options = array(
      array('1' => 'Kuchen', 'class' => 'cake'), 
      array('2' => 'Kekse', 'class' => 'biscuits'), 
      array('3' => 'Eis', 'class' => 'iceCream'), 
     ); 
     $attributes = array(
      'legend' => false, 
      'default' => '1' 
     ); 
     echo $this->Form->radio('INCOMETYPE', $options, $attributes); 
    ?> 
</div> 

但是doesn't工作。我希望你能幫忙。謝謝:)

回答

0

如果你打算在其他地方使用它,你可以擴展FormHelper來實現這個功能。如果這是一次性的,你最好手工製作標記。使用$ this-> Form-> radio產生的代碼給你一個開始。

+0

感謝您的幫助。手工操作的問題是驗證者不記得選定的值。在文檔準備好的情況下使用jquery添加類是否是一種好方法?還是那個糟糕的編碼?那麼,這真的是一個一個。 – Karl