Every time I get into working with forms, I find myself wondering why things 
have been done in a certain way.
One thing that occurs to me is that the 'tag' option for certain decorators, 
such as the label decorator, seems to be a stop-gap measure for complex 
elements that need to be wrapped in tags and which are not able to have this 
done using the parent elements decorator tree.
This can make things complex, such as where you want to change the tags 
wrapping the label element but you also want to assign a class to it.  Using 
the 'tag' option with the label decorator, this seems to be impossible.
Just wondering what the response would be to the concept of giving all 
decorators the ability to inherit child decorators, used something like this ...
$this->addDecorator('Label', array(    'decorator' => array('HtmlTag', array(   
     'tag' => 'p',        'class' => 'yourClass',        'id' => 'yourId'       
    )));
Alternately, you could limit it to HtmlTag and just have ...
$this->addDecorator('Label', array(    'htmltag' => array(        'tag' => 'p', 
       'class' => 'yourClass',        'id' => 'yourId'      )));

Implementation would be along the same lines as in the label decorator, where 
if a decorator/htmltag has been set, it wraps the output of the parent 
decorator with that of the child before being appended / prepended to the 
content.
In this way, any element could have the current linear decorators, as well as 
stacked decorators on any aspect.  Any element could have multiple decorators, 
each wrapped in their own individual tags, which I think is tricky to 
accomplish now.Element decorators could be updated to reflect this change to 
produce the same output so that there are no compatibility issues.
Just wanted to put this out there.  I think it would add a lot of flexibility 
to the decorators as a whole, and perhaps make the whole decorator scheme 
easier to understand / adjust.
Also, does anyone know why it was decided that element labels should not be 
passed to a viewscript?  I've done it now, but it was a real hassle to try and 
make a viewscript insert the element label AND value.  In the end I made an 
alternate label decorator, otherwise I would have had to sneak the label in via 
attribs using a modified decorator, which felt a bit too much like a hack.
Cheers.

                                          

Reply via email to