You are here

public function MigrateUIWizard::form in Migrate 7.2

Build the form for the current step.

Return value

array

File

migrate_ui/migrate_ui.wizard.inc, line 373
Migration wizard framework.

Class

MigrateUIWizard
The base class for migration wizards. Extend this class to implement a wizard UI for importing into Drupal from a given source format (Drupal, WordPress, etc.).

Code

public function form(&$form_state) {
  drupal_set_title(t('Import from @source_title', array(
    '@source_title' => $this
      ->getSourceName(),
  )));
  $form_method = $this->currentStep
    ->getFormMethod();
  $form['title'] = array(
    '#prefix' => '<h2>',
    '#markup' => t('Step @step: @step_name', array(
      '@step' => $this->stepNumber,
      '@step_name' => $this->currentStep
        ->getName(),
    )),
    '#suffix' => '</h2>',
  );
  $form += call_user_func_array($form_method, array(
    &$form_state,
  ));
  $form['actions'] = array(
    '#type' => 'actions',
  );

  // Show the 'previous' button if appropriate. Note that #submit is set to
  // a special submit handler, and that we use #limit_validation_errors to
  // skip all complaints about validation when using the back button. The
  // values entered will be discarded, but they will not be validated, which
  // would be annoying in a "back" button.
  if ($this->currentStep != $this->firstStep) {
    $form['actions']['prev'] = array(
      '#type' => 'submit',
      '#value' => t('Previous'),
      '#name' => 'prev',
      '#submit' => array(
        'migrate_ui_wizard_previous_submit',
      ),
      '#limit_validation_errors' => array(),
    );
  }

  // Show the Next button only if there are more steps defined.
  if ($this->currentStep == $this->lastStep) {
    $form['actions']['finish'] = array(
      '#type' => 'submit',
      '#value' => t('Save import settings'),
    );
    $form['actions']['migrate'] = array(
      '#type' => 'submit',
      '#value' => t('Save import settings and run import'),
      '#submit' => array(
        'migrate_ui_wizard_migrate_submit',
      ),
    );
  }
  else {
    $form['actions']['next'] = array(
      '#type' => 'submit',
      '#value' => t('Next'),
      '#name' => 'next',
      '#submit' => array(
        'migrate_ui_wizard_next_submit',
      ),
      '#validate' => array(
        'migrate_ui_wizard_next_validate',
      ),
    );
  }
  return $form;
}