开发者

Add multiple element groups into one display group using Zend_Form

I'm using Zend_Form to output my form and I am trying to group button element开发者_如何学编程s within 's and then add them to a fieldset.

The best I have managed is:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>
</fieldset>
<fieldset id="fieldset-group2">
    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

where the two element groups are within two separate display groups. I have done this by setting the DisplayGroup HtmlTag Decorator 'tag' option to 'div.

What I am looking to achieve is this:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>

    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

where the two div's are within the one display group.

I was hoping I could use the 'openOnly' and 'closeOnly' options that are available to the HtmlTag Decorator, but they are not available for DisplayGroups.

Apart from extending the Zend_View_Helper_Fieldset to do what I want is there a better way of doing this?


'decorators'=>array('FormElements',
                     array(array('divtag'=>'HtmlTag'),'options'=>array('tag'=>'div')),
                     array(array('fstag'=>'HtmlTag'),'options'=>array('tag'=>'fieldset','openOnly'=>true)),
                   )

openOnly/closeOnly can be used with DisplayGroups too


They always say you can write your own decorators. What you have to do is not extend the view_helper but write your own decorator. The decorator here is not the fieldset afaik but the FormElements inside and used by fieldset. It is the FormElements decorator which is not design to handle the div's you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜