lib: Automatically flatten subform values in ConfigForm::getValues()

Zend returns values from subforms grouped by their names and we have several places where we manually extract them. ConfigForm::getValues() does this automatically now.
This commit is contained in:
Eric Lippmann 2015-11-26 15:34:08 +01:00
parent 64bed9867f
commit 395201eee9
1 changed files with 18 additions and 1 deletions

View File

@ -5,9 +5,9 @@ namespace Icinga\Forms;
use Exception;
use Zend_Form_Decorator_Abstract;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Web\Notification;
use Icinga\Application\Config;
/**
* Form base-class providing standard functionality for configuration forms
@ -21,6 +21,23 @@ class ConfigForm extends Form
*/
protected $config;
/**
* {@inheritdoc}
*
* Values from subforms are directly added to the returned values array instead of being grouped by the subforms'
* names.
*/
public function getValues($suppressArrayNotation = false)
{
$values = parent::getValues($suppressArrayNotation);
foreach (array_keys($this->_subForms) as $name) {
// Zend returns values from subforms grouped by their names, but we want them flat
$values = array_merge($values, $values[$name]);
unset($values[$name]);
}
return $values;
}
/**
* Set the configuration to use when populating the form or when saving the user's input
*