我drupal_get_form('event_signup_form')
用来将我的自定义窗体嵌入一个块中。表单已按预期方式呈现,但是提交表单不会触发任何操作。
表单函数本身被调用event_signup_form($form, &$form_state)
,而提交函数被调用,event_signup_form_submit($form, &$form_state)
但是没有被调用。
我正在使用hook_block_view来显示表单:
function event_block_view($delta = '') {
$blocks = array();
if ($delta ...) {
$blocks['content'] = drupal_render(drupal_get_form('event_signup_form'));
}
}
我设法使它正常工作-这是(存根)如何:
function hook_block_view($delta = '') {
$blocks['content'] = drupal_render(drupal_get_form('event_signup_form'));
}
function event_signup_form() {
// Register form submit handler, same goes for validation handler
$form['#submit'][] = 'event_signup_form_submit';
return $form;
}
function event_signup_form_submit($form, &$form_state) {
// This is now triggered
}