File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1397,12 +1397,32 @@ protected function validateFormAnswer($input): bool {
13971397 $ this ->isAnswersValid = !in_array (false , $ fieldValidities , true );
13981398
13991399 if ($ this ->isAnswersValid ) {
1400+ $ form = $ this ->getForm ();
1401+ $ domain = PluginFormcreatorForm::getTranslationDomain ($ form ->getID ());
14001402 foreach ($ this ->questionFields as $ id => $ field ) {
14011403 if (!$ this ->questionFields [$ id ]->isPrerequisites ()) {
14021404 continue ;
14031405 }
1406+ // Count the errors in session
1407+ $ errors_count = $ _SESSION ['MESSAGE_AFTER_REDIRECT ' ][ERROR ]
1408+ ? count ($ _SESSION ['MESSAGE_AFTER_REDIRECT ' ][ERROR ])
1409+ : 0 ;
14041410 if (PluginFormcreatorFields::isVisible ($ field ->getQuestion (), $ this ->questionFields ) && !$ this ->questionFields [$ id ]->isValid ()) {
1405- $ this ->isAnswersValid = false ;
1411+ $ new_errors_count = $ _SESSION ['MESSAGE_AFTER_REDIRECT ' ][ERROR ]
1412+ ? count ($ _SESSION ['MESSAGE_AFTER_REDIRECT ' ][ERROR ])
1413+ : 0 ;
1414+
1415+ if ($ new_errors_count <= $ errors_count ) {
1416+ // If there are new errors, we add a message to the user
1417+ $ field_name = __ ($ field ->getQuestion ()->fields ['name ' ], $ domain );
1418+ Session::addMessageAfterRedirect (
1419+ sprintf (__ ('Answer is invalid in %1$s ' , 'formcreator ' ), $ field_name ),
1420+ true ,
1421+ ERROR
1422+ );
1423+ }
1424+
1425+ $ this ->isAnswersValid = false ;
14061426 }
14071427 }
14081428 }
You can’t perform that action at this time.
0 commit comments