You are here

public static function ElementSubmit::addCallback in Inline Entity Form 8

Adds the trigger callback to the given submit element.

Parameters

array $element: The submit element.

array $complete_form: The complete form.

1 call to ElementSubmit::addCallback()
ElementSubmit::attach in src/ElementSubmit.php
Attaches the #ief_element_submit functionality to the given form.

File

src/ElementSubmit.php, line 53

Class

ElementSubmit
Provides #ief_element_submit, the submit version of #element_validate.

Namespace

Drupal\inline_entity_form

Code

public static function addCallback(&$element, $complete_form) {
  if (empty($element['#submit'])) {

    // Drupal runs either the button-level callbacks or the form-level ones.
    // Having no button-level callbacks indicates that the form has relied
    // on form-level callbacks, which now need to be transferred.
    $element['#submit'] = $complete_form['#submit'];
  }
  $element['#submit'] = array_merge([
    [
      get_called_class(),
      'trigger',
    ],
  ], $element['#submit']);

  // Used to distinguish between an inline form submit and main form submit.
  $element['#ief_submit_trigger'] = TRUE;
  $element['#ief_submit_trigger_all'] = TRUE;
}