如何为选择标签元素设置类



如何为选择元素添加标注分类?如果不在树枝模板中这样做,这甚至可能吗?

呈现的表单选择元素:

<div>
    <label class="required">Type</label>
    <div id="AddNewAdType_type">
        <input type="radio" id="AddNewAdType_type_0" name="AddNewAdType[type]" required="required" value="b">
        <label for="AddNewAdType_type_0" class="required">one</label> // add  css class here
        <input type="radio" id="AddNewAdType_type_1" name="AddNewAdType[type]" required="required" value="s">
        <label for="AddNewAdType_type_1" class="required">two</label> // add css class here
    </div>  
</div>

例如:

//...
    ->add("currency", "choice",[
            'choices'=>[
                '1' => 'one',
                '2' => 'two'
            ],
        'expanded' => true,
        'choice_attr' =>[
            'class' => 'cssClassName' //won't work
            ]
    ])
//...
 ->add("currency", "choice",[
            'choices'=>[
                '1' => 'one',
                '2' => 'two'
            ],
        'expanded' => true,
        'label_attr' =>[
            'class' => 'cssClassName' 
            ]
    ])

干杯!

相关内容

  • 没有找到相关文章

最新更新