You are here

function homebox_block_edit_form_builder_submit in Homebox 7.2

Same name and namespace in other branches
  1. 6.3 homebox.module \homebox_block_edit_form_builder_submit()
  2. 6.2 homebox.module \homebox_block_edit_form_builder_submit()
  3. 7.3 homebox.module \homebox_block_edit_form_builder_submit()

Save settings for the block and render a replacement with the updated settings.

1 string reference to 'homebox_block_edit_form_builder_submit'
homebox_block_edit_form_builder in ./homebox.module
Get an edit form from the implementing module and add the standard buttons and submit handling.

File

./homebox.module, line 740
Homebox main file, takes care of global functions settings constants, etc.

Code

function homebox_block_edit_form_builder_submit($form, &$form_state) {
  list($page, $block) = $form_state['build_info']['args'];
  $user_blocks = _homebox_get_user_settings($page, TRUE);

  // Make sure needed keys exist.
  $user_blocks += array(
    $block->key => array(),
  );
  $user_blocks[$block->key] = array_merge(array_flip(module_invoke($block->module, 'homebox_block_keys', $block)), $user_blocks[$block->key]);

  // Replace user settings with form values, when keys match.
  $user_blocks[$block->key] = array_merge($user_blocks[$block->key], array_intersect_key($form_state['values'], $user_blocks[$block->key]));
  _homebox_save_user_settings($page, $user_blocks);
  $form_state['redirect'] = FALSE;

  // Clear block-specific cache.
  drupal_theme_initialize();
  $block->edit_form = TRUE;
  cache_clear_all(homebox_get_cache_id($page, $block), 'cache_block');
}