2014-04-29 67 views

回答

2

['#options']數組可用於表單驗證回調。要覆蓋表單元素,請確保您通過參考傳遞$ form參數:

function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state) { 
    $view = $form_state['view']; 
    if ($view->name == 'press_center' && $view->current_display == 'page') { 
    $form['#validate'][] = 'MY_MODULE_date_filter_validate'; 
    } 
} 

function MY_MODULE_date_filter_validate(&$form, &$form_state) { 
    $form['year_month']['value']['month']['#options'] = array(1=>'Jan',2=>'Feb',3=>'Mar'); 
} 
相關問題