Form: Add our element and decorator paths instead of calling createIcingaFormElement
createIcingaFormElement lacks all stuff applied in Zend_Form::createElement().
This commit is contained in:
parent
26c0fe7637
commit
f9d7062476
|
@ -11,7 +11,6 @@ use Zend_View_Interface;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Form\Decorator\NoScriptApply;
|
use Icinga\Web\Form\Decorator\NoScriptApply;
|
||||||
use Icinga\Web\Form\Element\CsrfCounterMeasure;
|
use Icinga\Web\Form\Element\CsrfCounterMeasure;
|
||||||
use Icinga\Web\Form\FormElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for forms providing CSRF protection, confirmation logic and auto submission
|
* Base class for forms providing CSRF protection, confirmation logic and auto submission
|
||||||
|
@ -139,6 +138,21 @@ class Form extends Zend_Form
|
||||||
throw new LogicException('The option `onSuccess\' is not callable');
|
throw new LogicException('The option `onSuccess\' is not callable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zend's plugin loader reverses the order of added prefix paths thus trying our paths first before trying
|
||||||
|
// Zend paths
|
||||||
|
$this->addPrefixPaths(array(
|
||||||
|
array(
|
||||||
|
'prefix' => 'Icinga\\Web\\Form\\Element\\',
|
||||||
|
'path' => Icinga::app()->getLibraryDir('Icinga/Web/Form/Element'),
|
||||||
|
'type' => static::ELEMENT
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'prefix' => 'Icinga\\Web\\Form\\Decorator\\',
|
||||||
|
'path' => Icinga::app()->getLibraryDir('Icinga/Web/Form/Decorator'),
|
||||||
|
'type' => static::DECORATOR
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,9 +478,7 @@ class Form extends Zend_Form
|
||||||
$options = array('decorators' => static::$defaultElementDecorators);
|
$options = array('decorators' => static::$defaultElementDecorators);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($el = $this->createIcingaFormElement($type, $name, $options)) === null) {
|
|
||||||
$el = parent::createElement($type, $name, $options);
|
$el = parent::createElement($type, $name, $options);
|
||||||
}
|
|
||||||
|
|
||||||
if ($el && $el->getAttrib('autosubmit')) {
|
if ($el && $el->getAttrib('autosubmit')) {
|
||||||
$noScript = new NoScriptApply(); // Non-JS environments
|
$noScript = new NoScriptApply(); // Non-JS environments
|
||||||
|
@ -738,25 +750,6 @@ class Form extends Zend_Form
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new element located in the Icinga Web 2 library
|
|
||||||
*
|
|
||||||
* @param string $type The type of the element
|
|
||||||
* @param string $name The name of the element
|
|
||||||
* @param mixed $options The options for the element
|
|
||||||
*
|
|
||||||
* @return NULL|FormElement NULL in case the element is not found in the Icinga Web 2 library
|
|
||||||
*
|
|
||||||
* @see Form::$defaultElementDecorators For Icinga Web 2's default element decorators.
|
|
||||||
*/
|
|
||||||
protected function createIcingaFormElement($type, $name, $options = null)
|
|
||||||
{
|
|
||||||
$className = 'Icinga\\Web\\Form\\Element\\' . ucfirst($type);
|
|
||||||
if (class_exists($className)) {
|
|
||||||
return new $className($name, $options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render this form
|
* Render this form
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue