Skip to content
Snippets Groups Projects
Commit 6a21040f authored by Jürgen Haas's avatar Jürgen Haas Committed by Jürgen Haas
Browse files

Issue #3302292 by jurgenhaas, rkoller: Do not show success message when trying...

Issue #3302292 by jurgenhaas, rkoller: Do not show success message when trying to save a model that contains errors
parent b5daf042
No related branches found
No related tags found
1 merge request!226Issue #3280069: eca_base: Provide an action for translating text
......@@ -182,9 +182,16 @@ class EcaController extends ControllerBase {
$editUrl = Url::fromRoute('entity.eca.edit_form', ['eca' => mb_strtolower($modeller->getId())], ['absolute' => TRUE])->toString();
$response->addCommand(new RedirectCommand($editUrl));
}
$message = new MessageCommand('Successfully saved the model.', NULL, [
'type' => 'status',
]);
if (!$modeller->hasError()) {
$message = new MessageCommand('Successfully saved the model.', NULL, [
'type' => 'status',
]);
}
else {
$message = new MessageCommand('Model contains error(s) and can not be saved.', NULL, [
'type' => 'error',
]);
}
}
catch (\Exception $ex) {
// @todo Log details about the exception.
......@@ -204,6 +211,7 @@ class EcaController extends ControllerBase {
$response->addCommand(new MessageCommand($message, NULL, ['type' => $type], FALSE));
}
}
$this->messenger()->deleteAll();
return $response;
}
......
......@@ -183,13 +183,16 @@ class Modellers {
->set('conditions', [])
->set('actions', []);
$modeller->readComponents($config);
if (!$modeller->hasError()) {
// Only save model if reading its components succeeded without errors.
$config->save();
$config->getModel()
->setData($modeller)
->save();
if ($modeller->hasError()) {
// If the model contains error(s), don't save it and do not ask for a
// page relead, because that would cause data loss.
return FALSE;
}
// Only save model if reading its components succeeded without errors.
$config->save();
$config->getModel()
->setData($modeller)
->save();
return $requiresReload;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment