传递不同的班级名称

时间:2012-02-29 18:13:45

标签: symfony1 symfony-1.4

我的确有以下表格:

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

我得到了下面的HTML。

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

我想更改表格中的类名称。它不应该是radio_list。我想用自己的名字命名? 我怎样才能在&#39;地区&#39;

中进行

以下操作无法正常运行并更改<li>的类:

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

谢谢!

贡纳尔

这是我完整的小部件:

        $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)),
    ));

1 个答案:

答案 0 :(得分:2)

您需要使用renderer_options,因为sfWidgetFormSelectRadio会使用自己的选项覆盖传递的属性。

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