index:
switch($key) {
...
case 'min_year':
if (is_numeric($value)) {
Search::newInstance()->addConditions(sprintf("%st_item_motorcycle_attr.i_year >= %d", DB_TABLE_PREFIX, $value));
$has_conditions = true;
}
break;
case 'max_year':
if (is_numeric($value)) {
Search::newInstance()->addConditions(sprintf("%st_item_motorcycle_attr.i_year <= %d", DB_TABLE_PREFIX, $value));
$has_conditions = true;
}
break;
default:
break;
}
form:
<div class="row one_input">
<h6><?php _e('Year', 'motorcycles_attributes'); ?></h6>
<select name="min_year" id="min_year">
<option value=""><?php _e('Min Year', 'motorcycles_attributes'); ?></option>
<?php
$minYr = array();
for ($a = 2016; $a > 1970; $a--) {
$minYr['id'] = $a;
$minYr['name'] = $a;
?>
<option value="<?php echo $minYr['id']; ?>" <?php if ($min_yr == $minYr['id']) { echo 'selected'; } ?>><?php echo $minYr['name'] ?></option>
<?php } ?>
</select>
<select name="max_year" id="max_year">
<option value=""><?php _e('Max Year', 'motorcycles_attributes'); ?></option>
<?php
$maxYr = array();
for ($b = 2016; $b > 1970; $b--) {
$maxYr['id'] = $b;
$maxYr['name'] = $b;
?>
<option value="<?php echo $maxYr['id']; ?>" <?php if ($max_yr == $maxYr['id']) { echo 'selected'; } ?>><?php echo $maxYr['name'] ?></option>
<?php } ?>
</select>
</div>