You are here

function config_pages_form_wrapper in Config Pages 7

Form callback wrapper: create or edit a config_pages.

Parameters

$config_pages: The config_pages object being edited by this form.

See also

config_pages_edit_form()

1 string reference to 'config_pages_form_wrapper'
ConfigPagesUIController::hook_menu in ./config_pages.admin.inc
Overrides hook_menu() defaults. Main reason for doing this is that parent class hook_menu() is optimized for entity type administration.

File

./config_pages.admin.inc, line 81
ConfigPages editing UI.

Code

function config_pages_form_wrapper($type) {
  $config_pages = config_pages_create(array(
    'type' => $type,
  ));

  // Add the breadcrumb for the form's location.
  config_pages_set_breadcrumb();

  // Check if config type exists.
  $config_type = config_pages_get_types($config_pages->type);
  if (empty($config_type)) {
    drupal_set_message(t('Config type @type no longer exists', array(
      '@type' => $config_pages->type,
    )), 'error');
    return '';
  }

  // Show context message.
  if (!empty($config_pages->context) && empty($_POST)) {
    $label = config_pages_context_label($config_pages->context);
    drupal_set_message(t('Please note that this Page is context sensitive, current context is %label', array(
      '%label' => $label,
    )), 'warning');
  }

  // Load config of specified type for current context.
  $current_config = config_pages_load_entity($type, $config_pages->context);
  if (!empty($current_config)) {
    $config_pages = $current_config;
  }

  // Return configuration form.
  $form_content = drupal_get_form('config_pages_edit_form', $config_pages);
  $content = drupal_render($form_content);

  // If this config uses context we show context import form.
  if ($config_pages->context && empty($form_content['confirm'])) {
    $form_content = drupal_get_form('config_pages_import_form', $config_pages);
    $content .= drupal_render($form_content);
  }
  return $content;
}