You are here

private function SubmitButtonFormEnhancerTrait::locateSubmitButtonsR in Flexiform 8

Locate the submit buttons recursively.

1 call to SubmitButtonFormEnhancerTrait::locateSubmitButtonsR()
SubmitButtonFormEnhancerTrait::locateSubmitButtons in src/FormEnhancer/SubmitButtonFormEnhancerTrait.php
Locate any submit buttons in the form.

File

src/FormEnhancer/SubmitButtonFormEnhancerTrait.php, line 33

Class

SubmitButtonFormEnhancerTrait
Trait for submit buttons in form enhancers.

Namespace

Drupal\flexiform\FormEnhancer

Code

private function locateSubmitButtonsR($elements, $depth = 0) {
  $buttons = [];
  foreach (Element::children($elements) as $key) {
    if ($depth == 0 && $this->formDisplay
      ->getComponent($key)) {
      continue;
    }
    if (isset($elements[$key]['#type']) && $elements[$key]['#type'] == 'submit') {
      $buttons[implode('][', $elements[$key]['#array_parents'])] = $elements[$key]['#value'];
    }
    $buttons += $this
      ->locateSubmitButtonsR($elements[$key], $depth + 1);
  }
  return $buttons;
}