开发者

using zend form decorators

<div class="field50Pct">
 <div class="fieldItemLabel">
  <label for='First Name'>First Name:</label>
 </div>
 <div class="fieldItemValue">
  <input type="text" id="firstname" name="firstname" value="" />
 </div>
</div开发者_C百科>

<div class="clear"></div>

I want the code to appear like this in source code . how do i write the same thing in zend using decorators ?

The element is like

  $firstname = new Zend_Form_Element_Text('FirstName');
        $firstname->setLabel('FirstName')
                 ->setRequired(true)
                 ->addFilter('StripTags')
                 ->addFilter('StringTrim')
                 ->addErrorMessage('Error in First Name')
                 ->addValidator('NotEmpty');


This seems to work for me: (with <div class="clear"></div> after the input)

$firstname->setDecorators(array(
        'ViewHelper',
        'Description',
        'Errors',
        array('HtmlTag', array('tag' => 'div', 'class' => 'fieldItemValue')),
        array(array('labelDivOpen' => 'HtmlTag'), 
              array('tag' => 'div', 
                    'placement' => 'prepend', 
                    'closeOnly' => true)),
        'Label',
        array(array('labelDivClose' => 'HtmlTag'), 
              array('tag' => 'div', 
                    'class' => 'fieldItemLabel', 
                    'placement' => 'prepend', 
                    'openOnly' => true)),
        array(array('fieldDiv' => 'HtmlTag'), 
              array('tag' => 'div', 'class' => 'field50Pct')),
        array(array('divClear' => 'HtmlTag') , 
              array('tag' => 'div' ,
                    'class' => 'clear',
                    'placement' => 'append'))
    ));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜