Skip to content

Commit

Permalink
Form: Return values as null if element has "ignore" and "preserveDefa…
Browse files Browse the repository at this point in the history
…ult"

refs #12295
  • Loading branch information
N-o-X committed Jan 9, 2017
1 parent 1129a29 commit 277f4b0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions library/Icinga/Web/Form.php
Expand Up @@ -1276,6 +1276,30 @@ public function isValid($formData)
return parent::isValid($formData);
}

public function getValues($suppressArrayNotation = false)
{
$values = parent::getValues($suppressArrayNotation);
$eBelongTo = null;

if ($this->isArray()) {
$eBelongTo = $this->getElementsBelongTo();
}

foreach ($this->getElements() as $key => $element) {
if ($element->getIgnore() && $element->getDecorator('preserveDefault')) {
if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
if ('' !== (string)$belongsTo) {
$key = $belongsTo . '[' . $key . ']';
}
}
$merge = $this->_attachToArray(null, $key);
$values = $this->_array_replace_recursive($values, $merge);
}
}

return $values;
}

/**
* Remove all elements of this form
*
Expand Down

0 comments on commit 277f4b0

Please sign in to comment.