Button content in ZF2 forms

前端 未结 3 364
忘了有多久
忘了有多久 2021-01-14 15:53

How to edit the button content of a Button element (of a ZF2 form)? I can set a label, but i would like to insert some html code inside it.

    $this->add         


        
3条回答
  •  滥情空心
    2021-01-14 16:34

    If all you need is just an icon, using css is a much more simpler option, in form file you just add a custom css class to your button, and then in your style sheets add the icon to the class using before and content like this:

    $this->add(array(
            'type' => 'Button',
            'name' => 'submit',
            'options' => array(
                'label'   => 'Modifica',
            ),
            'attributes' => array(
                'type'  => 'submit',
                'class' => 'btn btn-warning custom-btn-with-icon'
            )
        ));
    

    then in css:

    .custom-btn-with-icon:before {
        content: '\uxf005'; // this is the unicode of the custom-char you need for your icon
        font-family: 'fontAwesome'; // and this is the icon font of your project
    }
    

提交回复
热议问题