0

问题:在视图中打印表单元素时,未创建表单标签

我的观点:

<?php
/****** print elements and inser label:: have to be done in this way for integrate cushycms ********/
echo $this->form->empty;
?>
 <label>Ad Title</label>
 <?php
 echo $this->form->adtitle;
 ?>
<label></label>
 <?php echo $this->form->adbody; ?>

我的表格(部分代码):

class MyForm extends Zend_Form
{
function init(){
   $empty = new Zend_Form_Element_Hidden("empty");
        $empty->removeDecorator('Label');
        $title = new Zend_Form_Element('adtitle');
        $title->removeDecorator('Label');

        $title//->setLabel('Ad Title')
                    ->setRequired('true')
                    ->addFilter('StripTags')
                    ->addFilter('StringTrim')
                    ->addValidator('NotEmpty')
                    ->setAttrib('MAXLENGTH',100)
                    ->setAttrib('Size',106);

        $title->getValidator('NotEmpty')
                    ->setMessage('Company Name can not be empty');

        $body = new Zend_Form_Element_Textarea('adbody');
        $body->removeDecorator('Label');
}
}

我得到的html(表单标签不存在):

<dd id="empty-element">
<input type="hidden" name="empty" value="" id="empty"></dd> <label>Ad Title</label>
 <dd id="adtitle-element">
<input type="text" name="adtitle" id="adtitle" value="" MAXLENGTH="100" Size="106"></dd><label></label>

 <dd id="adbody-element">
<textarea name="adbody" id="adbody" onKeyDown="javascript:limitText(this.form.countdown,400)" onKeyUp="javascript:limitText(this.form.countdown,400)" rows="24" cols="80"></textarea></dd> <label>chras left (maximum 400): </label>

非常感谢

4

1 回答 1

1

我认为您必须自己添加表单标签。

    <form action="<?= $this->escape($this->form->getAction() ?>"
          method="<?= $this->escape($this->form->getMethod() ?>"
    >

或使用

echo $this->form; 
于 2010-07-01T17:03:07.023 回答