欢迎各位兄弟 发布技术文章
这里的技术是共享的
在 page callback 的主函数中进行执行 验证吧
比如
function custom_twenty_three_ise_menu()
{
$items['query_modify_ise'] = array(
'title' => '查询更改ise',
'page callback' => 'custom_twenty_three_ise_query_ise',
'access arguments' => array('operation ise'),
);
return $items;
}
function custom_twenty_three_ise_query_ise()
{
$form = drupal_get_form('js_ise_form');
$query_ise_result = $_SESSION['ise_result'];
unset($_SESSION['ise_result']);
$output = array(
'first_para' => $form,
'second_para' =>$query_ise_result?array(
'#type' => 'markup',
'#markup' => "<table style='width: auto;'><tr><td>mac: {$query_ise_result['mac']} </td><td>权限组: {$query_ise_result['endpointgroup']} </td></tr></table>",
):array(),
);
return $output;
}
function js_ise_form()
{
$form['mac'] = array(
'#type' => 'textfield',
'#title' => t('mac地址:'),
'#size' => 30,
'#default_value' =>!empty($_SESSION['ise_result']['mac'])?$_SESSION['ise_result']['mac']:'' ,
);
$ise_groups = _ad_net_level_ise_value();
$ise_groups = array_values($ise_groups);//让键全部变成数字
$ise_groups = array(-1=>'请选择')+ $ise_groups;
$form['group'] = array(
'#type' => 'select',
'#options' => $ise_groups,
'#default_value' => !empty($_SESSION['ise_result']['group'])?$_SESSION['ise_result']['group']:''
);
$form['diqu'] = array('#type' => 'hidden', '#value' => _my_node_jses_terminal_manager_diqu());
$form['#method'] = 'get';
// $form['#action'] = 'query_modify_ise';
//提交按钮 //
$form['submit'] = array('#type' => 'submit', '#value' => t('查询'));
$form['submit1'] = array('#type' => 'submit', '#value' => t('更改'),'#validate'=>array('js_ise_form_validate'));
$form['#attributes']['class'] = 'js_ise_form_class';
$form['submit']['#validate'][] = 'js_ise_form_validate';
$form['mac']['value']['#element_ validate']=array('js_ise_form_validate');
// $e = kprint_r($form,TRUE);
// print $e;
return $form;
}
function js_ise_form_validate($form, &$form_state)
function js_ise_form_submit($form, &$form_state)
程序不执行 js_ise_form_validate js_ise_form_submit 方法 我找不到什么原因,为什么不执行这个metho为get form表单
我们在 主程序 custom_twenty_three_ise_query_ise 中执行验证 validate 和提交 submit的工作
见 /node-admin/19345 大约是说 get form 表单 默认自己本身就是提交的话,所以就不执行validate和submit了
来自 https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7.x
note: if you change '#method' to 'GET' then no validate or submit handlers will be called.