Zend <dt> <dd> decorators: what do I lose by removing them

人盡茶涼 提交于 2019-12-06 09:08:52

They are solely for structuring the output of your Zend Form elements in a definition list. Whether your form renders errors is controlled through the Error Decorator.

See this series of articles by Matthew Weier O'Phinney:

and Rob Allen's Zend_Form Tutorial:

1) It's simplest and maybe the best practice to change appearance of forms via CSS, not by markup (by writing your own decorators), at least, when you're not experienced-well programmer. By removing DdDt decorator, lots of possibilities of CSS, such as input fields/labels/error-lists positioning, coloring, indenting and so on are lost. For example, to <dt> or <dd> you can add own class in form initialization, which later can be styled, satisfying your specific needs.

See code:

$comment = $this->createElement('textarea','comment',array(
    'label'=>'Post a comment',
    'required'=>true
))
  ->setDecorators(array(
    'ViewHelper', 
    'label', 
    'Errors', 
    array(
       'HtmlTag', 
       array(
          'tag' => 'dd', 
          'class'=>'elevatedField'
       )
    ) 
 ))
; 

Now in CSS stylesheet in .elevatedField{} rule you may define specific look for this textarea field. Actually, this example is not for default DdDt decorator, but it's explaining well ways of utilizing <dd> tag. Almost the same is for default DdDt decorator.

Look here what can be achieved with only css: http://robertbasic.com/blog/styling-the-default-zend_form-layout/ And it's not a limit.

2) Semantics of html markup is lost too, which almost have no meaning, at least for today.

Also, DdDt are not used by Zend_Form itself for error reporting - there is another standard decorator named 'Errors' for this needs.

$element->removeDecorator('DtDdWrapper');

OR $element->clearDecorators(); and setting your own decorator;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!