Validation Drupal:带参数和响应页面的全周期表单

Validation Drupal:带参数和响应页面的全周期表单,validation,drupal,forms,parameters,Validation,Drupal,Forms,Parameters,我正试图用参数和响应页面制作一个完整的周期表单。表单运行正常,但响应页面显示为黑色。任何人都有一个建议或榜样 function module99_menu(){ $items = array(); // inital form $items['module-99'] = array( 'title' => t('Export'), // Page title 'page callback' =&g

我正试图用参数和响应页面制作一个完整的周期表单。表单运行正常,但响应页面显示为黑色。任何人都有一个建议或榜样

function module99_menu(){
  $items = array();

    // inital form
    $items['module-99'] = array(
        'title'            => t('Export'),       // Page title
        'page callback'    => 'fn_module99',       // function to call when this page is called
        'access arguments' => array('access content'),  // An array of arguments to pass to the access callback function. 
        'description' => t('Export'),
        'type' => MENU_CALLBACK,
    );


    // response page
    $items['my_module-99-response/%/%'] = array(

        'title'            => t('Response Page'),           // Page title
        'page callback'    => 'fn_module99_response',       // function to call when this page is called
        'page arguments'   => array(0,1),                   // pass with arg(0) and arg(1) 
        'access arguments' => array('access content'),      
        'description'      => t('Export - response form'),
        'access callback'  => TRUE,
        'type'             => MENU_CALLBACK,
    );

function fn_module99() {
  return drupal_get_form('module99_my_form');
}


function module99_my_form_validate($form, &$form_state) {
  // do some validation 
}


function module99_my_form_submit($form, &$form_state) {
    // do some stuff
    drupal_set_message(t('The form has been submitted.'));  
    $parms = "p1="  .  "A" . "&p2=" . "B" ;
    $form_state['redirect'] = array('my_module-99-response', $parms);
}

function fn_module99_response($parm1,$parm2) { 
    $output =  $parm1 . $parm2;
    return $output;
}


function module99_my_form($form_state){

    $form = array();

     $form['email'] = array( 
         '#type' => 'textfield', 
         '#title' => t('E-mail address') ,
         '#size' => 64, 
         '#maxlength' => 64, 
         '#required' => TRUE, 
     ); 

    $form['submit'] = array( 
         '#type' => 'submit', 
         '#value' => t('Save'), 
     ); 

    return $form;
}

我不知道这是否有帮助,但是标准的方法是在钩子菜单上使用drupal_get_表单,表单id作为参数。我不知道你想用这些论点做什么

$items['my_module-99-response/'] = array(

    'title'            => t('Response Page'),           // Page title
    'page callback'    => 'drupal_get_form',      
    'page arguments'   => array('fn_module99_response'),     
    'access arguments' => array('access content'),      
    'description'      => t('Export - response form'),
    'access callback'  => TRUE,
    'type'             => MENU_CALLBACK,
);
还应使用“”属性在表单中指定提交处理程序(确保传递数组)。在进行验证时,以同样的方式进行验证

function module99_my_form($form_state){

$form = array();

 $form['email'] = array( 
     '#type' => 'textfield', 
     '#title' => t('E-mail address') ,
     '#size' => 64, 
     '#maxlength' => 64, 
     '#required' => TRUE, 
 ); 

$form['submit'] = array( 
     '#type' => 'submit', 
     '#value' => t('Save'), 
 );
$form['#submit'] = array('module99_my_form_submit') ;
$form['#validate'] = array('module99_my_form_validate') ;

return $form;
}

您应该稍微更改重定向:

$form_state['redirect'] = array("my_module-99-response/$param_a/$param_b");
另外,在
hook_菜单中
要更改页面参数:

$items['my_module-99-response/%/%'] = array(
    'page arguments'   => array(1,2),
);
这将匹配url中的两个
%
,因为0是
'my_module-99-response'

$form_state['redirect'] = array("my_module-99-response/$param_a/$param_b");
这非常有效,除了drupal用编码破坏斜杠