DirectorObjectForm: allow missing elements...

...when defining display groups, but only specific ones. I still want
to see exceptions for all the others
This commit is contained in:
Thomas Gelf 2016-03-30 19:51:29 +02:00
parent f25b8a5070
commit e4b609c647
1 changed files with 17 additions and 1 deletions

View File

@ -162,10 +162,26 @@ abstract class DirectorObjectForm extends QuickForm
if (! is_array($elements)) { if (! is_array($elements)) {
$elements = array($elements); $elements = array($elements);
} }
// These are optional elements, they might exist or not. We still want
// to see exception for other ones
$skipLegally = array('check_period_id');
$skip = array();
foreach ($elements as $k => $v) { foreach ($elements as $k => $v) {
if (is_string($v)) { if (is_string($v)) {
$elements[$k] = $this->getElement($v); $el = $this->getElement($v);
if (!$el && in_array($v, $skipLegally)) {
$skip[] = $k;
continue;
} }
$elements[$k] = $el;
}
}
foreach ($skip as $k) {
unset($elements[$k]);
} }
if (! array_key_exists($group, $this->displayGroups)) { if (! array_key_exists($group, $this->displayGroups)) {