March 2019
Intermediate to advanced
580 pages
15h 3m
English
So, up to now, we have seen how other modules can make changes to our form. That means adding new form elements, changing existing ones, etc. But what about our validation and submit handlers (those methods that get called when the form is submitted). How can those be altered?
Typically, for the forms defined as we did, it's pretty simple. Once we alter the form and inspect the $form array, we can find a #submit key, which is an array that has one item—::submitForm. This is simply the submitForm() method on the form class. So, what we can do is either remove this item and add our own function, or simply add another item to that array:
/** * Implements hook_form_FORM_ID_alter(). */ function my_module_form_salutation_configuration_form_alter(&$form, ...
Read now
Unlock full access