Skip to content

Instantly share code, notes, and snippets.

@tenken
Created March 23, 2012 18:00
Show Gist options
  • Save tenken/2173251 to your computer and use it in GitHub Desktop.
Save tenken/2173251 to your computer and use it in GitHub Desktop.
php 5 "closure"
<?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