You are here

protected function FormManglerService::attachFormSubmit in Rabbit Hole 2.x

Same name and namespace in other branches
  1. 8 src/FormManglerService.php \Drupal\rabbit_hole\FormManglerService::attachFormSubmit()

Adds extra form submit based on the provided submit locations.

1 call to FormManglerService::attachFormSubmit()
FormManglerService::addRabbitHoleOptionsToForm in src/FormManglerService.php
Common functionality for adding rabbit hole options to forms.

File

src/FormManglerService.php, line 482

Class

FormManglerService
Provides necessary form alterations.

Namespace

Drupal\rabbit_hole

Code

protected function attachFormSubmit(&$form, $submit_location, $submit_handler) {
  foreach ($submit_location as $location) {
    $array_ref =& $form;
    if (is_array($location)) {
      foreach ($location as $subkey) {
        $array_ref =& $array_ref[$subkey];
      }
    }
    else {
      $array_ref =& $array_ref[$location];
    }
    $array_ref[] = $submit_handler;
  }
}