You are here

function spaces_form_presets in Spaces 5.2

Same name and namespace in other branches
  1. 6 spaces.module \spaces_form_presets()
  2. 6.2 spaces.module \spaces_form_presets()

Preset options form that can be reused by implementing modules.

Parameters

$space: A space object.

Return value

A FormAPI array structure.

3 calls to spaces_form_presets()
spaces_basic_form in ./spaces_admin.inc
spaces_user_user in ./spaces_user.module
Implementation of hook_user().
_spaces_og_form_alter_group in ./spaces_og.module
Group node form_alter()

File

./spaces.module, line 1112

Code

function spaces_form_presets($space) {
  $default_presets = variable_get('spaces_default_presets', array());
  if (isset($space->preset)) {
    $default_preset = $space->preset;
  }
  else {
    if (isset($default_presets[$space->type])) {
      $default_preset = $default_presets[$space->type];
    }
    else {
      $default_preset = NULL;
    }
  }

  // Radios for presets
  $form = array(
    '#tree' => false,
    '#theme' => 'spaces_form_presets',
  );
  $form['preset'] = array(
    '#title' => t('Preset'),
    '#type' => 'radios',
    '#required' => true,
    '#options' => array(),
    '#default_value' => $default_preset,
  );
  $form['info'] = array();
  foreach (spaces_presets($space->type) as $id => $preset) {
    $form['preset']['#options'][$id] = $preset['name'];
    $form['info'][$id] = array(
      '#type' => 'item',
      '#title' => $preset['name'],
      '#description' => $preset['description'],
    );
  }
  return $form;
}