You are here

function spaces_preset_form_submit in Spaces 6.2

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_preset_form_submit()
  2. 6 spaces_admin.inc \spaces_preset_form_submit()

Submit handler for spaces preset form.

File

./spaces_admin.inc, line 236

Code

function spaces_preset_form_submit($form, &$form_state) {

  // Retrieve the space object from the form
  $space = $form_state['values']['space'];
  $preset = array(
    'name' => '',
    'description' => '',
    'features' => array(),
    'settings' => array(),
    'locked' => array(),
  );

  // Set name / description
  $preset['name'] = $form_state['values']['preset']['name'];
  $preset['description'] = $form_state['values']['preset']['description'];

  // Setting features & locks is easy
  $preset['features'] = $form_state['values']['features'];
  $preset['weights'] = $form_state['values']['weights'];
  $preset['locked'] = $form_state['values']['locked'];

  // Set setting values
  $settings = spaces_settings();
  foreach ($form_state['values']['settings'] as $setting => $value) {
    $preset['settings'][$setting] = $settings[$setting]
      ->submit($space, $value);
  }

  // Allow space_type to have its own preset values
  $preset[$space->type] = $space
    ->submit($form_state['values']);
  spaces_preset_save($space->type, $form_state['values']['preset']['id'], $preset);
  $form_state['redirect'] = 'admin/build/spaces';
}