Bit of a shocker of a subject line but I'm a bit busy to think of a
better one right now! The "cascading" is with reference to the way CSS
works really .
What I'm after is just some confirmation that the current general flow
for the setting of default decorators with Zend_Form has to be
something like this:
- instantiate form
- setup element 1
- setup element 2
- setup element 3
- clear all current decorators
- set my own element defaults
- render
...or...
- instantiate form
- setup element 1
- clear current decorators for element 1
- set my own decorators for element 1
- setup element 2
- clear current decorators for element 2
- set my own decorators for element 2
- setup element 3
- clear current decorators for element 3
- set my own decorators for element 3
- render
?
The reason I ask is that I'd like to be able to work like so:
- instantiate form
- clear all current decorators
- set my own element defaults
- setup element 1
- setup element 2 but tweak slightly from default
- setup element 3
- render
With the affect working a bit like a subclass or the way CSS works
whereby I clear and establish defaults before setting up my elements
and then can alter each one as needed in a "cascading" way.
This may already be possible but I wonder whether, judging by another
comment on another post, the way I'm setting it up breaks it. I'm
setting up each element by itself then adding it to the form like so...
$email = new Zend_Form_Element_Text('email', array('label' => 'Email
Address', 'size' => '30'));
$email->addValidator('emailAddress');
$this->addElement($email);
...and I wonder if using the factory approach would mean each element
would inherit my previously set custom decoration:
$this->addElement('text', 'email', array('label' => 'Email'));
The point really is to cut down on what currently feels to be a lot of
similar settings and the difficulty in having each element with just a
slight variation here and there on my defaults.
Hope that makes sense?
Cheers,
Nick