How to attach custom styles into zf2 forms

喜夏-厌秋 提交于 2019-12-24 03:07:32

问题


Maybe its obvious problem but could you please tell me how can I add custom css styles to forms created by standard view helpers in zend framework 2?

Im trying to attach some styles to forms created by ZfcUser


回答1:


Assign the class-attribute :)

    $this->add(array(
        'name' => 'element_name',
        'options' => array(
            'label' => 'element_label'
        ),
        'attributes' => array(
            'type' => 'element_type',
            'class'  => 'testing'
        )
    ));

Since you want to extend an existing form, you could either grab the Form and then $form->get('elementname')->setAttribute('class','blubb'); or you overwrite the Service-Form from ZfCUser with your custom form that has all styles attached, given above example.




回答2:


Please refer to this post, maybe the Partial method is the flexible and light choice.



来源:https://stackoverflow.com/questions/13134802/how-to-attach-custom-styles-into-zf2-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!