You are here

public function EntityForm::attachSubmitHandler in Acquia Content Hub 8

Attach submit handler to form actions.

Parameters

array &$form_actions: Form actions.

string $submit_handler_name: Submit handler's name.

File

src/Form/EntityForm.php, line 103

Class

EntityForm
Defines a form that alters entity form to add a Content Hub form.

Namespace

Drupal\acquia_contenthub\Form

Code

public function attachSubmitHandler(array &$form_actions, $submit_handler_name) {
  foreach (array_keys($form_actions) as $action) {
    if ($action === 'preview' || !isset($form_actions[$action]['#type']) || $form_actions[$action]['#type'] !== 'submit') {
      continue;
    }
    array_unshift($form_actions[$action]['#submit'], $submit_handler_name);
  }
}