本文整理汇总了PHP中Zend_Form_Element::setDisableLoadDefaultDecorators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::setDisableLoadDefaultDecorators方法的具体用法?PHP Zend_Form_Element::setDisableLoadDefaultDecorators怎么用?PHP Zend_Form_Element::setDisableLoadDefaultDecorators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element
的用法示例。
在下文中一共展示了Zend_Form_Element::setDisableLoadDefaultDecorators方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addElement
/**
* @see Zend_Form::addElement
*
* We have to override this, because we have to set some special decorators
* on a per-element basis (checkboxes and submit buttons have different
* decorators than other elements)
*
* @param string|Zend_Form_Element $element
* @param string $name
* @param array|Zend_Config $options
*/
public function addElement($element, $name = null, $options = null)
{
$element->setDisableLoadDefaultDecorators(true);
parent::addElement($element, $name, $options);
if (!$element instanceof Zend_Form_Element && $name !== null) {
$element = $this->getElement($name);
} else {
$element->setDecorators($this->_getDefaultElementDecorator($element));
}
if ($element instanceof Zend_Form_Element_File) {
$this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
if (!$element->getDescription()) {
$element->setDescription('Add File...');
}
}
if ($element instanceof Zend_Form_Element_Submit || $element instanceof Zend_Form_Element_Reset || $element instanceof Zend_Form_Element_Button) {
if (!$element instanceof Zend_Form_Element_Reset && !$element instanceof Zend_Form_Element_Button) {
$class = 'btn-primary';
} else {
if ($element instanceof Zend_Form_Element_Button && $element->getAttrib('type') === 'submit') {
$class = 'btn-primary';
} else {
$class = 'btn-default';
}
}
$element->setAttrib('class', trim('btn ' . $class . ' ' . $element->getAttrib('class')));
$this->_addActionsDisplayGroupElement($element);
} else {
$element->setAttrib('class', trim('form-control ' . $element->getAttrib('class')));
}
if ($element instanceof Zend_Form_Element_Radio || $element instanceof Zend_Form_Element_MultiCheckbox) {
$multiOptions = array();
foreach ($element->getMultiOptions() as $value => $label) {
$multiOptions[$value] = ' ' . $label;
}
$element->setMultiOptions($multiOptions);
$element->setAttrib('labelclass', 'checkbox');
if ($element->getAttrib('inline')) {
$element->setAttrib('labelclass', 'checkbox inline');
}
if ($element instanceof Zend_Form_Element_Radio) {
$element->setAttrib('labelclass', 'radio');
}
if ($element->getAttrib('inline')) {
$element->setAttrib('labelclass', 'radio inline');
}
$element->setOptions(array('separator' => ''));
}
if ($element instanceof Zend_Form_Element_Hidden) {
$element->setDecorators(array('ViewHelper'));
}
if ($element instanceof Zend_Form_Element_Textarea && !$element->getAttrib('rows')) {
$element->setAttrib('rows', 3);
}
if ($element->isRequired()) {
$element->setAttrib('required', 'required');
}
return $this;
}