2

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

user1650441
  • 455
  • 3
  • 12

2 Answers2

13

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.

Aydin Hassan
  • 1,465
  • 2
  • 20
  • 41
Sam
  • 16,435
  • 6
  • 55
  • 89
0

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

Community
  • 1
  • 1
John Yin
  • 8,057
  • 4
  • 25
  • 25
  • why use partials? just extend the already existing view helpers... they exist for this reason – NDM Jun 11 '14 at 14:45