简体   繁体   中英

Zend Form Decorators for theme

I got a new theme for which i need to edit my decorators.

Most of it i got working except for the checkbox and radio.

<!-- Previously -->
<div class="form-group ">
    <label for="mobileTheme" class="col-lg-2 control-label optional">Mobiel thema</label>
    <div class="col-lg-5">
        <div class="checkbox">
            <input type="hidden" name="mobileTheme" value="0" />
            <input type="checkbox" name="mobileTheme" id="mobileTheme" value="1" class=" " />
        </div>
        <span class="help-block">Redirect mobiele gebruikers naar een eigen domein met eigen thema</span>
    </div>
</div>

<!-- After -->
<div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
        <div class="checkbox">
            <label>
                <input type="checkbox" value="">
                <i class="input-helper"></i>
                Remember me
            </label>
        </div>
    </div>
</div>

My decorator looks like this now:

'checkbox' => array(
            'decorators' => array(
                'ViewHelper',
                array(array('input' => 'HtmlTag'), array('tag' => 'div', 'class' => 'checkbox')),
                array('Errors', array('class' => 'help-inline')),
                array('Description', array('tag' => 'span', 'class' => 'help-block')),
                array('Label', array('class' => 'col-lg-2 control-label')),
                array('HtmlTag', array('tag' => 'div', 'class' => 'col-lg-5')),
                'ElementWrapper'
            ),
            'options' => array(
                'class' => '',
            ),
        ),

The issue i'm struggling with is that i don't know how to order the decorators right so that label is now within the col-*-* class

I got it working,

'checkbox' => array(
            'decorators' => array(
                'ViewHelper',
                array('AdditionalElement', array('placement' => 'APPEND', 'tag' => 'i', 'class' => 'input-helper')),
                array(array('input' => 'HtmlTag'), array('tag' => 'div', 'class' => 'checkbox')),
                array('Errors', array('class' => 'help-inline')),
                array('Description', array('tag' => 'span', 'class' => 'help-block')),
                array('HtmlTag', array('tag' => 'div', 'class' => 'col-lg-5')),
                array('Label', array('class' => 'col-lg-2 control-label')),
                'ElementWrapper'
            ),
            'options' => array(
                'class' => '',
            ),
        ),

AdditionalElement is my own custom class for implementing any piece of html.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM