如何使MultiCheckBox标签变粗还是强?

时间:2015-03-02 11:33:08

标签: zend-framework2 zend-form zend-form-element zend-form2

我有以下多个检查框:

   $this->add(array(
        'type' => 'DoctrineModule\Form\Element\ObjectMultiCheckbox',

        'name' => 'directPractice',
        'options' => array(
           'label' => 'A. Check all direct practice field education assignments',

         **EDIT 1:**
         'label_attributes' => array(
                'class'  => 'label-multicheckbox-group'
            ),


            'object_manager' => $this->getObjectManager(),
            'target_class' => 'OnlineFieldEvaluation\Entity\FieldEducationAssignments', //'YOUR ENTITY NAMESPACE'
            'property' => 'directPractice', //'your db collumn name'
            'value_options' => array(
                '1' => 'Adults',
                '2' => 'Individuals',
                '3' => 'Information and Referral',
                '4' => 'Families',
            ),
        ),
        'attributes' => array(
            'value' => '1', //set checked to '1'
            'multiple' => true,
        )
    ));

如何使以下部分加粗? 使用label_attributes使所有标签都变为粗体,我只希望multibox的主标签是粗体。

'label' => 'A. Check all direct practice field education assignments',

编辑1:将label_attributes添加到"选项"

当我添加label_attributes为@itrascastro建议时,所有标签都变为粗体,我只希望顶部标签变为粗体:multicheckbox

3 个答案:

答案 0 :(得分:0)

尝试将此添加到您的选项中:

'options'    => array(
    'label_attributes' => array(
        'class'  => 'myCssBoldClass'
    ),
    // more options
),

答案 1 :(得分:0)

每个值选项accepts an array of options

例如

'value_options' => [
    [
        'label' => 'Adults',
        'label_attributes' => [
            'class' => 'my-bold-class',
        ],
        'attributes' => [],
        'value' => 1,
        'selected' => false,
        'disabled' => false,
    ],
    '2' => 'Individuals',
    '3' => 'Information and Referral',
    '4' => 'Families',
],

我添加了一些你可以定义的其他值;它们显然是可选的。

答案 2 :(得分:0)

由于没有内置选项来为顶部标签执行此操作,因此我使用jQuery来完成此任务:

$("label[for]").each(function(){
    $(this).addClass("label-bold");
});
相关问题