mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
lib/form: Fix default element decorators but breaking noscript layout
Replaced `ElementWrapper' and `HelpText' with Zend's `HtmlTag' and `Label' respectively. Instances of Zend_Form_Element returned by `Form::createElements()' now receive our desired default decorators. refs #5525
This commit is contained in:
parent
8478ef3fce
commit
d4c4ab7b2c
@ -99,7 +99,15 @@ class Form extends Zend_Form
|
|||||||
if ($this->onSuccess !== null && false === is_callable($this->onSuccess)) {
|
if ($this->onSuccess !== null && false === is_callable($this->onSuccess)) {
|
||||||
throw new LogicException('The option `onSuccess\' is not callable');
|
throw new LogicException('The option `onSuccess\' is not callable');
|
||||||
}
|
}
|
||||||
|
if (! isset($options['elementDecorators'])) {
|
||||||
|
$options['elementDecorators'] = array(
|
||||||
|
'ViewHelper',
|
||||||
|
'Errors',
|
||||||
|
array('Description', array('tag' => 'span', 'class' => 'description')),
|
||||||
|
'Label',
|
||||||
|
array('HtmlTag', array('tag' => 'div'))
|
||||||
|
);
|
||||||
|
}
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,8 +341,12 @@ class Form extends Zend_Form
|
|||||||
'submit',
|
'submit',
|
||||||
'btn_submit',
|
'btn_submit',
|
||||||
array(
|
array(
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'label' => $this->submitLabel
|
'label' => $this->submitLabel,
|
||||||
|
'decorators' => array(
|
||||||
|
'ViewHelper',
|
||||||
|
array('HtmlTag', array('tag' => 'div'))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -357,36 +369,23 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
public function createElement($type, $name, $options = null)
|
public function createElement($type, $name, $options = null)
|
||||||
{
|
{
|
||||||
$el = parent::createElement($type, $name, $options);
|
if (is_array($options) && ! isset($options['disableLoadDefaultDecorators'])) {
|
||||||
|
$options['disableLoadDefaultDecorators'] = true;
|
||||||
if ($el) {
|
}
|
||||||
if (strpos(strtolower(get_class($el)), 'hidden') !== false) {
|
$el = parent::createElement($type, $name, $options);
|
||||||
$el->setDecorators(array('ViewHelper'));
|
if ($el && $el->getAttrib('autosubmit')) {
|
||||||
} else {
|
$el->addDecorator(new NoScriptApply()); // Non-JS environments
|
||||||
$el->removeDecorator('HtmlTag');
|
$class = $el->getAttrib('class');
|
||||||
$el->removeDecorator('Label');
|
if (is_array($class)) {
|
||||||
$el->removeDecorator('DtDdWrapper');
|
$class[] = 'autosubmit';
|
||||||
|
} elseif ($class === null) {
|
||||||
if ($el->getAttrib('autosubmit')) {
|
$class = 'autosubmit';
|
||||||
// Need to add this decorator first or it interferes with the other's two HTML otherwise
|
} else {
|
||||||
$el->addDecorator(new NoScriptApply()); // Non-JS environments
|
$class .= ' autosubmit';
|
||||||
$class = $el->getAttrib('class');
|
}
|
||||||
if (is_array($class)) {
|
$el->setAttrib('class', $class); // JS environments
|
||||||
$class[] = 'autosubmit';
|
unset($el->autosubmit);
|
||||||
} elseif ($class === null) {
|
|
||||||
$class = 'autosubmit';
|
|
||||||
} else {
|
|
||||||
$class .= ' autosubmit';
|
|
||||||
}
|
|
||||||
$el->setAttrib('class', $class); // JS environments
|
|
||||||
unset($el->autosubmit);
|
|
||||||
}
|
|
||||||
|
|
||||||
$el->addDecorator(new ElementWrapper());
|
|
||||||
$el->addDecorator(new HelpText());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +555,6 @@ class Form extends Zend_Form
|
|||||||
if ($this->loadDefaultDecoratorsIsDisabled()) {
|
if ($this->loadDefaultDecoratorsIsDisabled()) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$decorators = $this->getDecorators();
|
$decorators = $this->getDecorators();
|
||||||
if (empty($decorators)) {
|
if (empty($decorators)) {
|
||||||
if ($this->viewScript) {
|
if ($this->viewScript) {
|
||||||
@ -565,12 +563,11 @@ class Form extends Zend_Form
|
|||||||
'form' => $this
|
'form' => $this
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$this->addDecorator('FormElements')
|
$this
|
||||||
//->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form'))
|
->addDecorator('FormElements')
|
||||||
->addDecorator('Form');
|
->addDecorator('Form');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user