Skip to content

Commit

Permalink
Form: Implement form element attribute ignoreDefault
Browse files Browse the repository at this point in the history
refs #6080
  • Loading branch information
N-o-X committed Jan 13, 2017
1 parent 1623722 commit 07372d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions library/Icinga/Web/Form.php
Expand Up @@ -1133,6 +1133,31 @@ public function populate(array $defaults)
return parent::populate($defaults);
}

/**
* {@inheritdoc}
*/
public function getValues($suppressArrayNotation = false) {
$values = parent::getValues($suppressArrayNotation);
foreach ($values as $key => & $value){
$el = $this->getElement($key);
if ($el) {
if ($el->getAttrib('ignoreDefault')) {
if (get_class($el) === 'Zend_Form_Element_Checkbox') {
if ($el->isChecked() === $this->getDefaultValue($key)) {
$value = null;
}
} else {
if ($value === $this->getDefaultValue($key)) {
$value = null;
}
}
}
}
}

return $values;
}

/**
* Recurse the given form and unset all unchanged default values
*
Expand Down

0 comments on commit 07372d6

Please sign in to comment.