N°1598 - Improve user feedback on invalid transition: Display a better error message to the user in the portal

This commit is contained in:
Molkobain
2020-05-06 16:58:25 +02:00
parent 72f11c6a4d
commit 6a50b55a2a
3 changed files with 15 additions and 2 deletions

View File

@@ -341,6 +341,19 @@ class ObjectFormManager extends FormManager
}
// Building form from its properties
// - Consistency checks for stimulus form
if (isset($this->aFormProperties['stimulus_code']))
{
$aTransitions = MetaModel::EnumTransitions($sObjectClass, $this->oObject->GetState());
if (!isset($aTransitions[$this->aFormProperties['stimulus_code']]))
{
$aStimuli = Metamodel::EnumStimuli($sObjectClass);
$sStimulusLabel = $aStimuli[$this->aFormProperties['stimulus_code']]->GetLabel();
$sExceptionMessage = Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulusLabel, $this->oObject->GetName(), $this->oObject->GetStateLabel());
throw new Exception($sExceptionMessage);
}
}
// - The fields
switch ($this->aFormProperties['type'])
{