DirectorObjectForm: show inherited non-scalars...
...in select boxes. This should make it more obvious that invalid data has been inherited. refs #2288
This commit is contained in:
parent
09a0323ad6
commit
4c4f9541e5
|
@ -623,16 +623,16 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||
return;
|
||||
}
|
||||
|
||||
$txtInherited = ' ' . $this->translate(' (inherited from "%s")');
|
||||
$txtInherited = sprintf($this->translate(' (inherited from "%s")'), $inheritedFrom);
|
||||
if ($el instanceof ZfSelect) {
|
||||
$multi = $el->getMultiOptions();
|
||||
if (is_bool($inherited)) {
|
||||
$inherited = $inherited ? 'y' : 'n';
|
||||
}
|
||||
if (is_scalar($inherited) && array_key_exists($inherited, $multi)) {
|
||||
$multi[null] = $multi[$inherited] . sprintf($txtInherited, $inheritedFrom);
|
||||
$multi[null] = $multi[$inherited] . $txtInherited;
|
||||
} else {
|
||||
$multi[null] = $this->translate($this->translate('- inherited -'));
|
||||
$multi[null] = $this->stringifyInheritedValue($inherited) . $txtInherited;
|
||||
}
|
||||
$el->setMultiOptions($multi);
|
||||
} elseif ($el instanceof ExtensibleSet) {
|
||||
|
@ -640,7 +640,7 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||
$el->setAttrib('inheritedFrom', $inheritedFrom);
|
||||
} else {
|
||||
if (is_string($inherited) || is_int($inherited)) {
|
||||
$el->setAttrib('placeholder', $inherited . sprintf($txtInherited, $inheritedFrom));
|
||||
$el->setAttrib('placeholder', $inherited . $txtInherited);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,6 +648,11 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||
$el->setRequired(false);
|
||||
}
|
||||
|
||||
protected function stringifyInheritedValue($value)
|
||||
{
|
||||
return is_scalar($value) ? $value : substr(json_encode($value), 0, 40);
|
||||
}
|
||||
|
||||
public function setListUrl($url)
|
||||
{
|
||||
$this->listUrl = $url;
|
||||
|
|
Loading…
Reference in New Issue