You are here

public function SubmitButtonRedirect::processForm in Flexiform 8

Process Form Enhancer.

File

src/Plugin/FormEnhancer/SubmitButtonRedirect.php, line 89

Class

SubmitButtonRedirect
FormEnhancer for altering the redirects of submit buttons.

Namespace

Drupal\flexiform\Plugin\FormEnhancer

Code

public function processForm($element, FormStateInterface $form_state, $form) {
  foreach (array_filter($this->configuration) as $key => $redirect) {
    $array_parents = explode('::', $key);
    $button = NestedArray::getValue($element, $array_parents, $exists);
    if ($exists) {
      if (empty($button['#submit'])) {
        $button['#submit'] = !empty($form['#submit']) ? $form['#submit'] : [];
      }
      $button['#submit'][] = [
        $this,
        'formSubmitRedirect',
      ];
      $button['#submit_redirect'] = $redirect;
      NestedArray::setValue($element, $array_parents, $button);
    }
  }
  return $element;
}