답변:
다음 hook_form_FORM_ID_alter()
과 같은 방법 으로 모든 형식의 유효성 검사 함수를 양식에 추가 할 수 있습니다 .
function mymodule_form_article_node_form_alter(&$form, &$form_state, $form_id) {
// There will already be some validate handlers added so you need to add to the
// array rather than overwrite it.
$form['#validate'][] = 'mymodule_article_form_validate';
// As mentioned above you can add as many as you want
$form['#validate'][] = 'mymodule_article_form_validate_2';
}
function mymodule_article_form_validate($form, &$form_state) {
// Random example, if the title is 'test' throw an error
if ($form_state['values']['title'] == 'test') {
form_set_error('title', 'Title cannot be "test"');
}
}
if ($form_state['values']['field_custom']['und'][0]['value'] == 'Error') { //throw error }