我想强制Zend形式的Twitter Bootstrap风格.我现在遍历表单字段,并将表单信息写入我的bootstrap div构造.
我在Zend Framework 1(!)中看到,在装饰器中有一种方法可以做到这一点.但是由于某种原因,版本2的文档不涵盖这一点…
我想做这样的事情:
protected $_format = '<label for="%s">%s</label>' . '<input id="%s" name="%s" type="text" value="%s"/>'; public function render($content) { $element = $this->getElement(); $name = htmlentities($element->getFullyQualifiedName()); $label = htmlentities($element->getLabel()); $id = htmlentities($element->getId()); $value = htmlentities($element->getValue()); $markup = sprintf($this->_format,$name,$label,$id,$value); return $markup; }
有任何想法吗?
我现在使用部分我正在迭代属性,构建一些例外,例如CSRF和Submit …这样做很顺利:
原文链接:https://www.f2er.com/php/131324.html视图
echo $this->partial('partial/form-partial',array( 'form' => $this->form,'url' => $this->url('whatever',array('action' => 'add')))); ?>
局部
<?PHP $form = $this->form; $form->setAttribute ( 'action',$this->url () ); $form->prepare (); echo $this->form ()->openTag ( $form ); foreach ( $form as $element ) : ?> <div class="control-group <?PHP if($this->formElementErrors($element)) echo "error" ?>"> <label class="control-label"><?PHP echo $element->getLabel() ?></label> <div class="controls"> <?PHP echo $this->formElement ( $element ); if ($this->formElementErrors ( $element )) ?> <span class="help-inline"><?PHP echo $this->formElementErrors($element) ?></span> </div> </div> <?PHP endforeach; echo $this->form ()->closeTag ( $form ); ?>
这些例外是为了清楚的缘故而被排除在外