Filter by Select Attribute
Permalink
Hey! I have been trying and trying to figure out how to filter a select attribute all day. Figured out (thanks to JordanLev) how to display it dynamically but now how to filter the blasted thing. Alright. Here's my PHP/HTML to display:
And here's how I'm trying to filter (and it's not working at all):
The annual rainfall is an user attribute too if that means anything. :)
<span class='attribute_answer'>
<select name="annual_rainfall">
<option value="0">--</option>
<?php
Loader::model('attribute/type');
Loader::model('attribute/categories/collection');
$ak = UserAttributeKey::getByHandle('annual_rainfall');
$satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
$satc->setAttributeKey($ak);
$values = $satc->getOptions();
foreach ($values as $v) {
echo "<option id='".$v->ID."' value=".$v->ID.">".$v->value."</option>";
}
?>
</select>Viewing 15 lines of 16 lines. View entire code block.
And here's how I'm trying to filter (and it's not working at all):
$annual_rainfall = htmlentities(trim($_GET['annual_rainfall'])); $userList->filterByAnnualRainfall('annual_rainfall', $annual_rainfall, '=');
The annual rainfall is an user attribute too if that means anything. :)