/**
  * Returns a FieldList with which to create the main editing form.
  *
  * @return FieldList The fields to be displayed in the CMS.
  */
 public function getCMSFields()
 {
     // Get the CMS fields
     $fields = parent::getCMSFields();
     // Update the existing fields with labels
     $nameField = $fields->dataFieldByName("Title");
     if ($nameField) {
         $nameField->setRightTitle("Staff members name (John Smith etc)");
     }
     // Add the fields to the CMS
     $fields->addFieldToTab("Root.Main", TextField::create("Position", _t("StaffProfilePage.PositionTitle", "Position")), "Content");
     $fields->addFieldToTab("Root.Main", EmailField::create("Email", _t("StaffProfilePage.EmailTitle", "Email address")), "Content");
     $fields->addFieldToTab("Root.Main", TextField::create("Phone", _t("StaffProfilePage.PhoneTitle", "Phone")), "Content");
     $fields->addFieldToTab("Root.Categories", GridField::create("Categories", _t("StaffProfilePage.CategoriesTitle", "Categories"), $this->Categories(), StaffProfilePage_Category::getGridFieldConfig()));
     // Add the thumbnail field
     $uploadField = UploadField::create("Thumbnail", _t("StaffProfilePage.ThumbnailTitle", "Thumbnail"));
     $uploadField->setFolderName('Staff');
     $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     $sizeMB = 0.3;
     // MB
     $size = $sizeMB * 1024 * 1024;
     // Bytes
     $uploadField->getValidator()->setAllowedMaxFileSize($size);
     $fields->addFieldToTab("Root.Main", $uploadField, "Content");
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Get a list of categories related to this 
  * staff profiles holder page.
  * 
  * @return SS_List StaffProfilePage_Category
  */
 public function Categories()
 {
     // Create the output list
     $output = new ArrayList();
     // Get all the categories
     $categories = StaffProfilePage_Category::get();
     // Create the all category
     $allCategory = StaffProfilePage_Category::create();
     $allCategory->Title = "All";
     $allCategory->Selected = $this->categoryID === 0 ? true : false;
     $output->add($allCategory);
     // Add all the categories
     foreach ($categories as $category) {
         $category->Selected = $this->categoryID === $category->ID ? true : false;
         $output->add($category);
     }
     return $output;
 }