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