10851 Posts in 2517 Topics by 1793 members
|Go to End|
30 March 2010 at 4:31pm Last edited: 30 March 2010 4:33pm
I am currently trying to extend the Event Calendar and having a few headaches with what I am trying to achieve.
Basically I have a new classes SportEvent and SportEventHolder.
Each sport event has a category:
static $db = array(
'Category' => "Enum('International, National, Club, Special')",
I have extended the Sport holder filter to allow filitering on this:
public function getFilterFields()
$fields = parent::getFilterFields();
$fields->addFilterField(new DropdownField('SportEvent_Category','Category', singleton('SportEvent')->dbObject('Category')->enumValues()));
Now the thing I am having trouble with is figuring out a way I can have the category filter as optional. Is there any way to add 'All' to the drop down box and effectively have it ignore the second part of the filter?
One way of trying to get around it was removing the filter and having buttons for the categories, with them linked the calendar page with ?filter=1&filter_SortEvent_Category=Club added to the end of the url, but this only works if the user selects the category and then filters on date, not the other was around.
Any ideas would be much appreaciated. As you can probably guess I am developing the website for my work. We are the governing body of a sport and are wanting to display our official calendar in a much more user friendly way than our current website.
30 March 2010 at 5:41pm
It's been a while since I've been in that code, but I think this might work:
$fields->addFilterField($d = new DropdownField('SportEvent_Category','Category', singleton('SportEvent')->dbObject('Category')->enumValues()));
$d->setEmptyString('-- All --');
1 April 2010 at 2:13pm
Perfect, thank you very much.
|Go to Top|