2012-02-29 38 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