Commit 8e42342b authored by Navid Sassan's avatar Navid Sassan
Browse files

fixed problem with datalist import

parent 384bfcb4
......@@ -97,17 +97,6 @@ class DirectorDatafield extends DbObjectWithSettings
public static function import($plain, Db $db, $replace = false)
{
$properties = (array) $plain;
if (isset($properties['settings']->datalist)) {
// Just try to load the list, import should fail if missing
$list = DirectorDatalist::load(
$properties['settings']->datalist,
$db
);
} else {
$list = null;
}
$encoded = Json::encode($properties);
if (isset($properties['guid'])) {
......@@ -157,6 +146,20 @@ class DirectorDatafield extends DbObjectWithSettings
}
}
if (isset($properties['settings']->datalist)) {
// It is possible that the datalist does not exists yet, but is part of the new basket
try {
$list = DirectorDatalist::load(
$properties['settings']->datalist,
$db
);
} catch (NotFoundError $e) {
$list = null;
}
} else {
$list = null;
}
if ($list) {
unset($properties['settings']->datalist);
$properties['settings']->datalist_id = $list->get('id');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment