DirectorObjectForm: improve import handling

This commit is contained in:
Thomas Gelf 2015-07-30 11:43:33 +02:00
parent 6187777d08
commit 2643b6ae8c

View File

@ -116,10 +116,16 @@ abstract class DirectorObjectForm extends QuickForm
if ($object->supportsImports()) { if ($object->supportsImports()) {
if (array_key_exists('imports', $values)) { if (array_key_exists('imports', $values)) {
$object->imports()->set( $value = $values['imports'];
preg_split('/\s*,\s*/', $values['imports'], -1, PREG_SPLIT_NO_EMPTY)
); // 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; $handled['imports'] = true;
$object->clearImportedObjects();
} }
} }
@ -268,10 +274,12 @@ abstract class DirectorObjectForm extends QuickForm
); );
} }
if ($this->object->supportsImports()) { if ($object->supportsImports()) {
$this->getElement('imports')->setValue( $el = $this->getElement('imports');
implode(', ', $this->object->imports()->listImportNames()) if ($el) {
); $el->setMultiOptions($this->enumAllowedTemplates());
$el->setValue($object->imports()->listImportNames());
}
} }
if ($this->object->supportsCustomVars()) { if ($this->object->supportsCustomVars()) {