You are here

function oa_core_app_configure_form in Open Atrium Core 7.2

Creates a configure form for the current app.

File

./oa_core.module, line 409

Code

function oa_core_app_configure_form($form, &$form_state) {

  // blank for for now.  Other modules can alter this to add stuff
  $form = array();
  if (($app_name = arg(3)) && ($function = $app_name . '_oa_settings_form') && function_exists($function)) {
    $child_forms = call_user_func_array($function, array(
      &$form_state,
    ));

    // Add child forms as vertical tabs if exist.
    if (count($child_forms) > 1) {
      drupal_add_js("misc/collapse.js");
      drupal_add_js("misc/vertical-tabs.js");
      $form['oa_settings'] = array(
        '#type' => 'vertical_tabs',
        '#weight' => 99,
        '#prefix' => '<div class="oa-vertical-tabs">',
        '#suffix' => '</div>',
      );
      foreach ($child_forms as $key => $child_form) {
        $form[$child_form['caption']] = array(
          '#type' => 'fieldset',
          '#title' => $child_form['caption'],
          '#group' => 'oa_settings',
          '#attributes' => array(
            'class' => array(
              'collapsible',
            ),
          ),
        );
        $form[$child_form['caption']][] = $child_form['form'];
        if (!empty($child_form['submit'])) {
          $form['#submit'][] = $child_form['submit'];
        }
      }
    }
    elseif (count($child_forms)) {
      $child_form = reset($child_forms);
      $form['title']['#markup'] = '<h2>' . $child_form['caption'] . '</h2>';
      $form += $child_form['form'];
      if (!empty($child_form['submit'])) {
        $form['#submit'][] = $child_form['submit'];
      }
    }
  }
  return $form ? system_settings_form($form) : array(
    '#markup' => t('Unable to generate form'),
  );
}