You are here

function spaces_preset_form in Spaces 7

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_preset_form()
  2. 6.3 spaces.admin.inc \spaces_preset_form()
  3. 6 spaces_admin.inc \spaces_preset_form()
  4. 6.2 spaces_admin.inc \spaces_preset_form()
  5. 7.3 spaces.admin.inc \spaces_preset_form()

Generate a form snippet for choosing a spaces preset.

4 calls to spaces_preset_form()
spaces_preset_list in spaces_ui/export_ui/spaces_presets_export_ui.class.php
Presets form.
spaces_taxonomy_form_taxonomy_form_term_alter in spaces_taxonomy/spaces_taxonomy.module
Implements hook_form_alter() for taxonomy_form_term().
spaces_user_form_user_profile_form_alter in spaces_user/spaces_user.module
Implements hook_form_FORM_ID_alter().
_spaces_og_form_alter_group in spaces_og/spaces_og.pages.inc
Group node form_alter(). @TODO: repair default values on node previews.

File

./spaces.admin.inc, line 105

Code

function spaces_preset_form($presets, $type, $include_disabled = FALSE) {
  $types = spaces_types();
  $form = array(
    '#tree' => FALSE,
    '#title' => isset($types[$type]['title']) ? $types[$type]['title'] : '',
    '#theme' => 'spaces_preset_form',
    '#space_type' => $type,
  );
  $form["spaces_preset_{$type}"] = array(
    '#type' => 'radios',
    '#options' => array(),
    '#default_value' => variable_get("spaces_preset_{$type}", NULL),
  );
  foreach ($presets as $preset) {
    if (empty($preset->disabled) || $include_disabled) {

      // Default preset radio
      if (empty($preset->disabled)) {
        $form["spaces_preset_{$preset->space_type}"]['#options'][$preset->name] = '';
      }

      // Label
      $label = "<strong>" . t(check_plain($preset->title)) . "</strong>";
      $label .= "<div class='description'>" . t(check_plain($preset->description)) . "</div>";
      $form['labels'][$preset->name] = array(
        '#type' => 'markup',
        '#markup' => $label,
      );
    }
  }
  return $form;
}