mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
Form: Don't prevent disabled elements from getting overwritten..
..if someone just utilizes populate() programatically. refs #2509
This commit is contained in:
parent
ed5ba14df2
commit
eb343009bb
@ -1102,21 +1102,22 @@ class Form extends Zend_Form
|
|||||||
*
|
*
|
||||||
* @param Zend_Form $form
|
* @param Zend_Form $form
|
||||||
* @param array $defaults
|
* @param array $defaults
|
||||||
|
* @param bool $ignoreDisabled
|
||||||
*/
|
*/
|
||||||
protected function preserveDefaults(Zend_Form $form, array & $defaults)
|
protected function preserveDefaults(Zend_Form $form, array & $defaults, $ignoreDisabled = true)
|
||||||
{
|
{
|
||||||
foreach ($form->getElements() as $name => $element) {
|
foreach ($form->getElements() as $name => $element) {
|
||||||
if ((array_key_exists($name, $defaults)
|
if ((array_key_exists($name, $defaults)
|
||||||
&& array_key_exists($name . static::DEFAULT_SUFFIX, $defaults)
|
&& array_key_exists($name . static::DEFAULT_SUFFIX, $defaults)
|
||||||
&& $defaults[$name] === $defaults[$name . static::DEFAULT_SUFFIX])
|
&& $defaults[$name] === $defaults[$name . static::DEFAULT_SUFFIX])
|
||||||
|| $element->getAttrib('disabled')
|
|| (! $ignoreDisabled && $element->getAttrib('disabled'))
|
||||||
) {
|
) {
|
||||||
unset($defaults[$name]);
|
unset($defaults[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($form->getSubForms() as $_ => $subForm) {
|
foreach ($form->getSubForms() as $_ => $subForm) {
|
||||||
$this->preserveDefaults($subForm, $defaults);
|
$this->preserveDefaults($subForm, $defaults, $ignoreDisabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,6 +1144,11 @@ class Form extends Zend_Form
|
|||||||
if (($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false))) {
|
if (($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false))) {
|
||||||
$this->getView()->layout()->setLayout('wrapped');
|
$this->getView()->layout()->setLayout('wrapped');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To prevent a BC, this is here. The proper fix is to extend populate()
|
||||||
|
// and pass $ignoreDisabled through to preserveDefaults()
|
||||||
|
$this->create($formData)->preserveDefaults($this, $formData, false);
|
||||||
|
|
||||||
$this->populate($formData); // Necessary to get isSubmitted() to work
|
$this->populate($formData); // Necessary to get isSubmitted() to work
|
||||||
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
|
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
|
||||||
if ($this->isValid($formData)
|
if ($this->isValid($formData)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user