div
中にあるお問い合わせフォームをラップするに<li class ="af_title">
は、次のようにします。
$yourForm = new YourForm();
$yourForm->addDecorator(array('div' => 'HtmlTag'), array('tag' => 'div'));
$yourForm->addDecorator(array('li' => 'HtmlTag'), array('tag' => 'li', 'class' => 'af_title'));
編集:
あなたはdivフォーム要素について話しているようです。そのような要素は存在しませんが、簡単に作成できます。このためには、新しいフォーム要素(つまり、div要素)と、htmlの生成を処理するフォームビューヘルパーの2つが必要です。私は、これら2つの要素の簡単な例を準備して、私が何を意味するかを示すことができました。
APPLICATION_PATHのDiv.php。/ forms / Element:
class My_Form_Element_Div extends Zend_Form_Element {
/**
* Default form view helper to use for rendering
* @var string
*/
public $helper = 'formDiv';
public function __construct($spec, $options = null) {
parent::__construct($spec, $options);
$this->removeDecorator('label');
$this->removeDecorator('htmlTag');
}
}
APPLICATION_PATHのFormDiv.php。/ views / helpers:
class My_View_Helper_FormDiv extends Zend_View_Helper_FormElement {
public function formDiv($name, $value = null, $attribs = null) {
$class = '';
if (isset($attribs['class'])) {
$class = 'class = "'. $attribs['class'] .'"';
}
return "<li $class><div>$value</div></li>";
}
}
これにより、次のように、divフォーム要素をinit()メソッドの任意のフォーム要素に追加できます。
$div = new My_Form_Element_Div('mydiv');
$div->setValue('Contact form')->setAttrib('class', 'af_title');
$this->addElement($div);