You are here

function _popup_form in Popup 7

Same name and namespace in other branches
  1. 8 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 373

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_render($form);
  if ($attributes['ajax']) {
    $body = '<div class="ajax-form-wrapper">' . $body . '</div>';
  }
  if ($return == 'body') {
    return $body;
  }
  return popup_element($title, $body, $attributes);
}