Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Event Calendar filter troubles

Go to End

3 Posts   1229 Views


Community Member, 2 Posts

30 March 2010 at 4:31pm

Edited: 30/03/2010 4:33pm

Hi there,

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()));
return $fields;

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.


Forum Moderator, 4102 Posts

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 --');


Community Member, 2 Posts

1 April 2010 at 2:13pm

Perfect, thank you very much.