QuickForm: dedicated method for special options

This commit is contained in:
Thomas Gelf 2015-07-30 15:39:09 +02:00
parent 3c8f3a7ade
commit 1fc7f6e2cb

View File

@ -66,18 +66,28 @@ abstract class QuickForm extends Zend_Form
public function __construct($options = null) public function __construct($options = null)
{ {
if ($options !== null && array_key_exists('icingaModule', $options)) { parent::__construct($this->handleOptions($options));
$this->icingaModule = $options['icingaModule'];
$this->icingaModuleName = $this->icingaModule->getName();
unset($options['icingaModule']);
}
parent::__construct($options);
$this->setMethod('post'); $this->setMethod('post');
$this->setAction(Url::fromRequest()); $this->setAction(Url::fromRequest());
$this->createIdElement(); $this->createIdElement();
$this->regenerateCsrfToken(); $this->regenerateCsrfToken();
} }
protected function handleOptions($options = null)
{
if ($options === null) {
return $options;
}
if (array_key_exists('icingaModule', $options)) {
$this->icingaModule = $options['icingaModule'];
$this->icingaModuleName = $this->icingaModule->getName();
unset($options['icingaModule']);
}
return $options;
}
protected function addSubmitButtonIfSet() protected function addSubmitButtonIfSet()
{ {
if (false !== ($label = $this->getSubmitLabel())) { if (false !== ($label = $this->getSubmitLabel())) {