Created
March 23, 2012 18:00
-
-
Save tenken/2173251 to your computer and use it in GitHub Desktop.
php 5 "closure"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function courses_db_form_alter(&$form, $form_state, $form_id) { | |
if ($form['#id'] == 'views-exposed-form-catalog-listings-page' && $form_id == 'views_exposed_form') { | |
$max_comparator = function ($max) { | |
return function ($v) use ($max) { return (intval($v) > 0) ? $v < $max : TRUE; }; | |
}; | |
# this form value starts with "--Any--", we want to inlcude that always. | |
$form['field_coursedb_year_tid']['#options'] = | |
array_filter( | |
$form['field_coursedb_year_tid']['#options'], | |
$max_comparator(variable_get('current_schoolyear', 2012)) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment