Answers:
定制模块可hook_form_alter()
用于以任何形式剥离预览按钮表单元素:
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
// Look for any form provided by the contact module.
// If you want to target a specific form you'll use the whole form ID
// (e.g. Website feedback = 'contact_message_feedback_form').
if (strpos($form_id, 'contact_message_') !== FALSE) {
$form['actions']['preview']['#access'] = FALSE;
}
}
hook_form_form_id_alter()
钩了完整的代码段(适用于默认的联系表):function THEME_form_contact_message_feedback_form_alter(&$form, &$form_state, $form_id) { $form['actions']['preview']['#access'] = FALSE; }
有正在工作和测试中的补丁程序,但尚未提交https://www.drupal.org/project/drupal/issues/2960353。补丁程序可以在最新的D8上运行,但是在提交补丁程序之前,建议使用“隐藏预览按钮”模块https://www.drupal.org/project/hide_preview对其他表单页面也适用。以防万一,这有助于那些不熟悉钩子和贴片的人。