I used views exposed form to filter data, is it possible for me to add a v开发者_如何转开发alidation function to validate the input before it is handled by the views
Yes,
With a small custom module you can implement hook_form_alter().
I usually start with this:
<?php
function your_module_form_alter(&$form, &$form_state, $form_id){
drupal_set_message($form_id);
}
?>
once you get your views exposed filter form id, you operate inside of an "if"... so you don't alter all of your forms
<?php
function your_module_form_alter(&$form, &$form_state, $form_id){
if($form_id=="your_form_id"){
//add to the validation callback array( don't override it! )
$form['#validate'][] = '_your_custom_validation';
}
}
function _your_custom_validation($form, &$form_state){
//validate stuff, using form_set_error()
}
?>
an example validation function: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#validate
精彩评论