Zend Form: How do I make it bend to my will?

后端 未结 14 1504
你的背包
你的背包 2021-01-29 18:53

I\'ve read the manual many times, I\'ve scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused?

14条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-29 19:42

    Render each element individually in your view - for example

    
    
    Name: myForm->getElement('name')->render(); ?> some other text between the fields Birthdate: myForm->getElement('birthdate')->render(); ?>

    This maintains the ability to use the Zend_Form view helpers (i.e. to display error messages and maintain the values of the form fields when validation fails) but gives you full customization ability.

    If you want to go further, then turn off the default decorators of the individual form elements and then either attach your own to further customize exactly what tags are used (i.e. for error messages and labels) or don't use decorators at all (other than to render the form element itself) and then write all the surrounding HTML manually. Complete customization ability without losing the benefits of Zend_Form, both at the form level and at the view level.

提交回复
热议问题