I am building a website to learn languages.
I have a registration form with Register snippet and extra user fields. On registration the user must choose his native language and the language he wants to learn.
Before the registration process is completed I need to compare the languages ( the native language cannot be the same as the language he wants to learn ).
I tried with a custom validator but $hook (which contains all the values submitted in the form) is not accessible. In a custom validator I can only get the value for a single field at a time which is stored in $value
So i tried with a preHook which is better because in preHooks we have the possibilty to access all the values of the form with $hook->getValues(). In preHooks I can compare the languages and send an error if an incorrect language has been detected.
However the problem is preHooks is executed after validation which is not appropriate in my case: if the user enters an incorrect value in let’s say both the “email” and the “native language” fields, the register page will reload and display an error solely for the “email” field, because if validation fails the preHook snippet is not executed at all.
Per chance does someone have a solution for this ?