DirectorObjectForm: improve import handling

This commit is contained in:
Thomas Gelf 2015-07-30 11:43:33 +02:00
parent 6187777d08
commit 2643b6ae8c
1 changed files with 15 additions and 7 deletions

View File

@ -116,10 +116,16 @@ abstract class DirectorObjectForm extends QuickForm
if ($object->supportsImports()) {
if (array_key_exists('imports', $values)) {
$object->imports()->set(
preg_split('/\s*,\s*/', $values['imports'], -1, PREG_SPLIT_NO_EMPTY)
);
$value = $values['imports'];
// TODO: Compat for comma separated string, check if still needed
if (! is_array($value)) {
$value = preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
}
$object->imports()->set($value);
$handled['imports'] = true;
$object->clearImportedObjects();
}
}
@ -268,10 +274,12 @@ abstract class DirectorObjectForm extends QuickForm
);
}
if ($this->object->supportsImports()) {
$this->getElement('imports')->setValue(
implode(', ', $this->object->imports()->listImportNames())
);
if ($object->supportsImports()) {
$el = $this->getElement('imports');
if ($el) {
$el->setMultiOptions($this->enumAllowedTemplates());
$el->setValue($object->imports()->listImportNames());
}
}
if ($this->object->supportsCustomVars()) {