You are here

public function SubmitButtonLabel::processForm in Flexiform 8

Process Form Enhancer.

File

src/Plugin/FormEnhancer/SubmitButtonLabel.php, line 58

Class

SubmitButtonLabel
FormEnhancer for altering the labels of submit buttons.

Namespace

Drupal\flexiform\Plugin\FormEnhancer

Code

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