You are here

function demo_dump_form in Demonstration site (Sandbox / Snapshot) 7

Same name and namespace in other branches
  1. 6 demo.admin.inc \demo_dump_form()

Form builder to create a new snapshot.

1 string reference to 'demo_dump_form'
demo_menu in ./demo.module
Implements hook_menu().

File

./demo.admin.inc, line 126
Demonstration Site administrative pages.

Code

function demo_dump_form($form, &$form_state) {
  $form['#tree'] = TRUE;
  $form['dump']['filename'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#maxlength' => 128,
    '#description' => t('Allowed characters: a-z, A-Z, 0-9, dashes ("-"), underscores ("_") and dots.'),
  );
  $form['dump']['description'] = array(
    '#title' => t('Description'),
    '#type' => 'textarea',
    '#rows' => 2,
    '#description' => t('Leave empty to retain the existing description when replacing a snapshot.'),
  );
  $form['dump']['tables'] = array(
    '#type' => 'value',
    '#value' => demo_enum_tables(),
  );
  if (empty($form_state['demo']['dump_exists'])) {
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Create'),
    );
  }
  else {
    $form = confirm_form($form, t('Are you sure you want to replace the existing %name snapshot?', array(
      '%name' => $form_state['values']['dump']['filename'],
    )), 'admin/structure/demo', t('A snapshot with the same name already exists and will be replaced. This action cannot be undone.'));
  }
  return $form;
}