You are here

function flexiform_ajax_form_process in Flexiform 8

Ajax element process to add our library.

Can be added to any element that accepts ajax commands.

1 string reference to 'flexiform_ajax_form_process'
flexiform_element_info_alter in ./flexiform.module
Implements hook_element_info_alter().

File

./flexiform.module, line 93
Allow multiple entities to be used in an entity form display.

Code

function flexiform_ajax_form_process(&$element, FormStateInterface $form_state, &$complete_form) {
  if (isset($element['#flexiform_ajax_processed'])) {
    return $element;
  }

  // Initialize #flexiform_ajax_processed, so we do not process this element
  // again.
  $element['#flexiform_ajax_processed'] = FALSE;

  // Nothing to do if there are no Ajax settings.
  if (empty($element['#ajax'])) {
    return $element;
  }
  if (isset($element['#ajax']['event'])) {
    $element['#attached']['library'][] = 'flexiform/flexiform.ajax';
  }
  return $element;
}