You are here

function config_pages_import_form in Config Pages 7

Import form callback.

1 string reference to 'config_pages_import_form'
config_pages_form_wrapper in ./config_pages.admin.inc
Form callback wrapper: create or edit a config_pages.

File

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

Code

function config_pages_import_form($form, &$form_state, $config_pages) {
  $form['#config_pages'] = $config_pages;

  // List all existing entities of this type.
  $list = entity_load('config_pages', FALSE, array(
    'type' => $config_pages->type,
  ));
  foreach ($list as $item) {
    if ($item->context != $config_pages->context) {
      $options_context[$item->context] = config_pages_context_label($item->context);
    }
  }

  // Allow copy settings from another context.
  if (!empty($options_context)) {
    $form['import_context'] = array(
      '#type' => 'fieldset',
      '#title' => t('Import From Another Context'),
      '#description' => t('This action can not be undone!'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['import_context']['destination'] = array(
      '#type' => 'item',
      '#title' => t('Import To (current)'),
      '#markup' => config_pages_context_label($config_pages->context),
    );
    $form['import_context']['source'] = array(
      '#type' => 'select',
      '#title' => t('Import From'),
      '#options' => $options_context,
      '#default_value' => '',
    );
    $form['import_context']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Import'),
    );
  }
  return $form;
}