2
我想为所有节点编辑表单添加自定义验证。具体来说,将使任何图像字段alt和标题属性要求。但我还没有接触到那件作品。到目前为止,我有以下的代码,但由于某些原因,我的验证的辅助函数不会被调用:Drupal 7 - 尝试向所有节点编辑表单添加自定义验证
<?php
/*
* Implements hook_form_alter()
*/
function image_a11y_form_alter($form, &$form_state, &$form_id) {
// Do this for ALL node edit forms (not specific form ID)
if (isset($form['#node_edit_form']) && $form['#node_edit_form'] == TRUE) {
$form['#validate'][] = 'custom_validate';
}
}
function custom_validate($form, &$form_state){
// Custom validation here
}
我跟着几个例子我在网上找到并双击检查Drupal.org API文档。我不知道我做错了什么。