달을 선택적으로 만들 수있는 기본 제공 방법이 있는지 확실하지 않지만 가능한 해결 방법입니다. Year 필터는 Year 필터를, Year 필터 필터는 Year-Month 필터 필터를 추가 할 수 있습니다. 그런 다음 을 사용하여 노출 된 양식을 변경할 수 있습니다 (조건을 추가하여보기 및 표시 ID인지 확인하십시오). 양식이 제출 될 때 월이 선택되면 year_month 필드에 연도를 설정할 수 있도록 유효성 검사 콜백을 추가 할 수 있습니다.
이 방법은 테스트하지 않았지만 일반적으로 form_alter에 접근하는 방법입니다.
<?php
function my_module_form_views_exposed_form_alter(&$form, &$form_state) {
$view = $form_state['view'];
if ($view->name == 'my_view' && $view->current_display == 'my_display') {
// Assuming the year exposed filter is 'year' and year-month exposed filter
// is 'year_month'.
$form['year_month']['value']['year']['#access'] = FALSE; // Hides the year
$form['#validate'][] = 'my_module_my_view_filter_validate';
}
}
function my_module_my_view_filter_validate($form, &$form_state) {
$values = isset($form_state['values']) ? $form_state['values'] : array();
// When the month is set, grab the year from the year exposed filter.
if (isset($values['year_month']['value']['month'])) {
// If the year is not set, we have set a user warning.
if (!isset($values['year']['value']['year'])) {
drupal_set_message(t('Please select a year.'), 'warning');
}
else {
// Otherwise set the year in the year_month filter to the one from our
// year filter.
$year = $values['year']['value']['year'];
$form_state['values']['year_month']['value']['year'] = $year;
}
}
}
?>
감사합니다. 작동하는지 알려 드리겠습니다. 나는 그럴 것이라고 확신한다. – alouette