-- SiCo007 <[EMAIL PROTECTED]> wrote
(on Thursday, 27 March 2008, 05:45 AM -0700):
> I've just started to actually implement Zend Form, so far it's going well but
> it seems far too difficult (read over the top) to actually make changes to
> the way the form is displayed.
>
> Maybe I'm not understanding the documentation properly, but is it possible
> to remove all the default decorators from the form ($form = new
> Zend_Form(array('disableLoadDefaultDecorators' => true));) Only seems to
> remove the default form decorators? I want groups and elements stripped too?
>
> I've done it so far by handling the elements, then the groups, then specific
> submit button, cancel button and hidden elements, in my opinion I want
> something clean which I can then put my own code on to without having to
> disable everything first! (I do realise everyone is different, it just
> appears the ZF is focusing on trying to do everything, rather than forcing
> the developer to get their hands dirty!).
The disableLoadDefaultDecorators setting is per object; you need to
specify it for each form, group, sub form, and element separately. (For
the most part, we try not to have the form object communicate global
preferences to the items it contains).
It sounds to me like you might want a setting to of
'disableAllDefaultDecorators' that could be applied to the form and
propagate to all items created with the form; if so, please place a
request in the tracker.
Note, however, that you can specify the decorators you want *during*
configuration, and this will override the defaults (the defaults won't
even be loaded).
> Is there a way to change the decorators on all buttons, or all text boxes?
Yes: it's called extension. :-)
Create your own extensions of these classes and specify the decorators
you want in your subclasses (best way is by overriding the
loadDefaultDecorators() method). Then simply provide a prefixPath for
elements to the form object, and your custom elements will be utilized.
This is the best way to approach a situation where you know you will not
be using the shipped defaults.
Zend Framework classes are built to be extended; that's what OOP is all
about. In a component such as Zend_Form, it's the recommended way of
customizing it to suit your needs. Yes, there are many facilities for
customizing the rendering, but to make the customized rendering
re-usable, the easiest way is to extend the various classes and modify
them for your needs. Each component in Zend_Form has a section on
customization that you can use as a guide.
> Is it possible, if I develop a concrete layout decorator to render
> everything, based on the example in the manual (although I can't for the
> life of me find the example now), to tell the type of each form element and
> change the rendering?
Again, you should probably create your own custom elements, as it's the
cleanest approach.
There are some examples of creating custom elements in the manual, but
if you need more tips, please let me know.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/