/**
  * Contructor
  * @param type $controller
  * @param type $name
  */
 public function __construct($controller, $name)
 {
     //Administering categories
     if (CalendarConfig::subpackage_enabled('categories')) {
         $gridCategoryConfig = GridFieldConfig_RecordEditor::create();
         $GridFieldCategories = new GridField('Categories', '', PublicEventCategory::get(), $gridCategoryConfig);
         $fields = new FieldList($GridFieldCategories);
         $actions = new FieldList();
         $this->addExtraClass('CategoriesForm');
         parent::__construct($controller, $name, $fields, $actions);
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $categories = function () {
         //TODO: This should only be the case for public events
         return PublicEventCategory::get()->map()->toArray();
     };
     $categoriesField = ListboxField::create('Categories', 'Categories')->setMultiple(true)->setSource($categories());
     //If the quickaddnew module is installed, use it to allow
     //for easy adding of categories
     if (class_exists('QuickAddNewExtension')) {
         $categoriesField->useAddNew('PublicEventCategory', $categories);
     }
     $fields->addFieldToTab('Root.Main', $categoriesField);
 }