drupal ctools multistep向导

时间:2012-10-29 14:00:33

标签: drupal drupal-ctools

我正在尝试编写一个ctools多步向导,这是我的向导功能;

function _mymodule_adv_wizard($js=NULL, $step="step1") {

  $form_info = array();
  $form_info["id"]              = SK_ADV_WIZARD_ID;
  $form_info["path"]            = "tests/adv/mymodule/%step";

  $form_info["show trail"]      = TRUE;
  $form_info["show back"]       = TRUE;
  $form_info["show cancel"]     = TRUE;
  $form_info["show return"]     = TRUE;

  $form_info["next callback"]   = "_my_module_adv_wizard_on_next";
  $form_info["finish callback"] = "_my_module_adv_wizard_on_finish";
  $form_info["cancel callback"] = "_my_module_adv_wizard_on_cancel";

  $form_info["order"]           = array("step1" => t("Stap 1"), "step2" => t("Stap 2"), "step3" => t("Stap 3"), "step4" => t("Stap 4"), "step5" => t("Stap 5"), "step6" => t("Stap 6"), "step7" => t("Stap 7"), "step8" => t("Stap 8"));

  $form_info["forms"]           = array(); 
  $form_info["forms"]["step1"]  = array("form id" => "_my_module_adv_step1_form");
  $form_info["forms"]["step2"]  = array("form id" => "_my_module_adv_step2_form");
  $form_info["forms"]["step3"]  = array("form id" => "_my_module_adv_step3_form");
  $form_info["forms"]["step4"]  = array("form id" => "_my_module_adv_step4_form");
  $form_info["forms"]["step5"]  = array("form id" => "_my_module_adv_step5_form");
  $form_info["forms"]["step6"]  = array("form id" => "_my_module_adv_step6_form");
  $form_info["forms"]["step7"]  = array("form id" => "_my_module_adv_step7_form");
  $form_info["forms"]["step8"]  = array("form id" => "_my_module_adv_step8_form");

  $form_state = array("ajax" => FALSE, "object_id" => SK_ADV_OBJECT_ID, "object" => new stdClass());

  //initialize ctools wizard
  ctools_include("wizard");
  $form = ctools_wizard_multistep_form($form_info, $step, $form_state); 
  return theme('my_module_wrapper', array('formwrapper'  =>  $form, 'page'  =>  $step));
}

一切都很好,我可以单独访问页面,但按钮不打印,所以我不能去提交和验证功能。我有另一个与diff的向导。 id和form defs但它的作用就像一个魅力。可能是什么原因。

P.S。所有函数和变量都在上面的代码中声明。

2 个答案:

答案 0 :(得分:3)

您是否在第一步重置了表单数组?

function _my_module_adv_step1_form($form, &$form_state){
    $form = array(); // this remove your submit-buttons. Delete this line and your bottons will appear.
    //... your form elements...
}

答案 1 :(得分:1)

这不是一个答案,而是张贴作为答案,因为评论框不够用。

我最好的猜测是你需要在你的赢家上添加按钮。

function _my_module_adv_step1_form($form, &$form_state){
  ... your form elements...
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
    '#submit' => array('_my_module_adv_wizard_on_next'),
  );
}