I know very well how
hook_form_alter() is working in Drupal 7 and in Drupal 8, but the main topic here is how to do things OOP way.
How would you solve the following problem the OOP way?
Suppose you have a random form, for example the user login form.
- custom_module_A adds a checkbox to the form and a custom validation handler
- custom_module_B adds a textfield to the same form and another custom validation handler
The OOP way of altering the form is:
- intercepts the original UserLoginForm and directs to a CustomModuleNewForm- an extended class from user_login_form class
- Write a class that extends the user login form
I am unable to "grokh" how this can be solved the OOP way, by extending the form in custom_module_A and not having custom_module_A as a dependency for custom_module_B.
Basically, I am looking for OOP