2010-07-01 66 views
0

問題視圖 - 表單標籤形式的打印元件: 當鑑於形式的打印元件,不創建的窗體標籤Zend_Form的:當dod't創建

筆者認爲:

<?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; ?> 

MY表(代碼的一部分):

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> 

非常感謝您

回答

1

我認爲你必須通過你的自我補充的形式標記。

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

或者使用

echo $this->form; 
+0

非常感謝您! – Yosef 2010-07-01 18:31:12

+0

<形式行動= 「逃逸($這 - >形式 - >的getAction()?>」 方法= 「逃逸($這 - >形式 - > getMethod()?>」 > 不工作時,其只顯示沒有動作和方法的值

Yosef 2010-07-04 12:05:58