You are here

function _popup_form in Popup 8

Same name and namespace in other branches
  1. 7 includes/popup.api.inc \_popup_form()
  2. 7.x includes/popup.api.inc \_popup_form()
  3. 6.x includes/popup.api.inc \_popup_form()

File

includes/popup.api.inc, line 374

Code

function _popup_form($attributes, $return = FALSE) {
  $title = $attributes['title'] ? $attributes['title'] : 'form';
  if ($return == 'title') {
    return $title;
  }

  // Initialize args attribute.
  $attributes += array(
    'args' => array(),
  );

  // Add form_id at the beginning of the args array.
  array_unshift($attributes['args'], $attributes['form']);

  // Render form.
  $form = call_user_func_array('drupal_get_form', $attributes['args']);
  $body = \Drupal::service('renderer')
    ->render($form);
  if ($attributes['ajax']) {
    $body = '<div class="ajax-form-wrapper">' . $body . '</div>';
  }
  if ($return == 'body') {
    return $body;
  }
  return popup_element($title, $body, $attributes);
}