2012-02-29 41 views
1

我有以下形式:傳遞不同的類名

'region' => new sfWidgetFormChoice(array('expanded' => true,'choices' => $region)) 

我得到的folloing HTML。

<ul class="radio_list"> 
    <li> first... 
    <li> second.... 

我想更改表中類的名稱。它不應該是radio_list。我想用我自己的名字命名? 如何在'地區'做到這一點?

以下是不工作,改變了<li>類:

'region' => new sfWidgetFormChoice(array('expanded' => true,'choices' => $region), array('class' => 'your_class')) 

謝謝!

貢納爾

這是我的完整的Widget:

 $this->setWidgets(array(
     'recipename' => new sfWidgetFormInputText(array(), array('size' => '40', 'maxlength' => '150')), 
     'description' => new sfWidgetFormInputText(array(), array('size' => '40', 'maxlength' => '100')), 
     'ingredients' => new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35')), 
     'preparation' => new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35')), 
     'kis' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $kis)), 
     'category' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $category)), 
     'region' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $region)), 
    )); 
+0

還有一個類似的問題在這裏(http://stackoverflow.com/questions/2517328/sfwidgetformchoice-rendered-as-an-unordered-list),可以幫助你。 – 2012-03-01 09:44:42

回答

2

您需要使用renderer_options的是,由於sfWidgetFormSelectRadio覆蓋通過屬性與它自己的選擇。

new sfWidgetFormChoice(array(
    'expanded' => true, 
    'choices' => $region, 
    'renderer_options' => array(
     'class' => 'your_class' 
    ) 
); 
+0

是的!謝謝。我沒有得到symfony的語法,因爲我已經以某種方式嘗試了這種方式,但它不起作用。但你的方式正在工作!謝謝! (感謝!) – craphunter 2012-03-01 14:44:05