user1650441
user1650441

Reputation: 455

How to attach custom styles into zf2 forms

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

Upvotes: 2

Views: 4887

Answers (2)

John Yin
John Yin

Reputation: 8357

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

Upvotes: 0

Sam
Sam

Reputation: 16455

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.

Upvotes: 13

Related Questions