0
我創建了這兩個函數,以便能夠通過跟蹤SOF或其他信息上的不同主題來修改Drupal表單的驗證。但我從來沒有查詢進入驗證功能,我不明白爲什麼...驗證Drupal表單不起作用
/**
* Implements hook_form_FORM_ID_alter().
*/
function *****_form_simplenews_block_form_1_alter(&$form, &$form_state) {
// Modify some form settings
$form['mail']['#title_display'] = 'invisible';
$form['mail']['#size'] = 40;
$form['mail']['#attributes']['placeholder'] = t('Enter your email address');
$form['submit']['#value'] = t('OK');
$form['#validate'][0] = '*****_simplenews_block_form_validate';
}
/**
* Validate the mail address for simplenews
*
* @param $form
* @param $form_state
*/
function *****_simplenews_block_form_validate($form, &$form_state) {
kpr($form);die();
if (!valid_email_address($form_state['values']['mail']) && $form_state['values']['check_robot']) {
form_set_error('mail', t("Error, please try again"));
form_set_error('submit', "You are a robot.");
}
}
我去看看在Drupal的API(https://www.drupal.org/files/fapi_workflow_7.x_v1.1.png)的文檔,它似乎是我做的是什麼所以如果有人可以幫助我,我會很高興,提前謝謝你!