You are here

function commerce_alter_inline_forms in Commerce Core 8.2

Invokes inline form alter hooks for the given element's inline forms.

Parameters

array $element: The form element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

1 call to commerce_alter_inline_forms()
commerce_form_alter in ./commerce.module
Implements hook_form_alter().

File

./commerce.module, line 57
Defines common functionality for all Commerce modules.

Code

function commerce_alter_inline_forms(array &$element, FormStateInterface $form_state, array &$complete_form) {
  foreach (Element::children($element) as $key) {
    if (isset($element[$key]['#inline_form'])) {
      $inline_form =& $element[$key];

      /** @var \Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormInterface $plugin */
      $plugin = $inline_form['#inline_form'];

      // Invoke hook_commerce_inline_form_alter() and
      // hook_commerce_inline_form_PLUGIN_ID_alter() implementations.
      $hooks = [
        'commerce_inline_form',
        'commerce_inline_form_' . $plugin
          ->getPluginId(),
      ];
      \Drupal::moduleHandler()
        ->alter($hooks, $inline_form, $form_state, $complete_form);
    }
    commerce_alter_inline_forms($element[$key], $form_state, $complete_form);
  }
}