You are here

public function ctools_export_ui::edit_execute_form_wizard in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 plugins/export_ui/ctools_export_ui.class.php \ctools_export_ui::edit_execute_form_wizard()

Execute the wizard for editing.

For complex objects, sometimes a wizard is needed. This is normally activated by setting 'use wizard' => TRUE in the plugin definition and then creating a 'form info' array to feed the wizard the data it needs.

When creating this wizard, the plugin is responsible for defining all forms that will be utilized with the wizard.

Using 'add order' or 'edit order' can be used to ensure that add/edit order is different.

2 calls to ctools_export_ui::edit_execute_form_wizard()
ctools_export_ui::edit_execute_form in plugins/export_ui/ctools_export_ui.class.php
Execute the form.
ctools_export_ui::import_page in plugins/export_ui/ctools_export_ui.class.php
Page callback to import information for an exportable item.

File

plugins/export_ui/ctools_export_ui.class.php, line 889

Class

ctools_export_ui
Base class for export UI.

Code

public function edit_execute_form_wizard(&$form_state) {
  $form_info = $this
    ->get_wizard_info($form_state);

  // If there aren't any forms set, fail.
  if (empty($form_info['order'])) {
    return MENU_NOT_FOUND;
  }

  // Figure out if this is a new instance of the wizard
  if (empty($form_state['step'])) {
    $order = array_keys($form_info['order']);
    $form_state['step'] = reset($order);
  }
  if (empty($form_info['order'][$form_state['step']]) && empty($form_info['forms'][$form_state['step']])) {
    return MENU_NOT_FOUND;
  }
  ctools_include('wizard');
  $output = ctools_wizard_multistep_form($form_info, $form_state['step'], $form_state);
  if (!empty($form_state['complete'])) {
    $this
      ->edit_save_form($form_state);
  }
  elseif ($output && !empty($form_state['item']->export_ui_item_is_cached)) {

    // @todo this should be in the plugin strings
    drupal_set_message(t('You have unsaved changes. These changes will not be made permanent until you click <em>Save</em>.'), 'warning');
  }

  // Unset the executed flag if any non-wizard button was pressed. Those
  // buttons require special handling by whatever client is operating them.
  if (!empty($form_state['executed']) && empty($form_state['clicked_button']['#wizard type'])) {
    unset($form_state['executed']);
  }
  return $output;
}