コード例 #1
0
 public function getCMSFields()
 {
     $ImageField = UploadField::create('Photo');
     $ImageField->folderName = 'Staff';
     $ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     if ($this->ID == 0) {
         $categorydropdown = TextField::create('CategoryDisclaimer')->setTitle('Category')->setDisabled(true)->setValue('You can assign a category once you have saved the record for the first time.');
     } else {
         $categories = StaffCategory::get()->sort("Title ASC");
         $map = $categories ? $categories->map('ID', 'Title', 'Please Select') : array();
         if ($map) {
             $categorydropdown = DropdownField::create('StaffCategoryID')->setTitle('Category')->setSource($map);
             $categorydropdown->setEmptyString("-- Please Select --");
         } else {
             $categorydropdown = DropdownField::create('StaffCategoryID')->setTitle('Category')->setSource($map);
             $categorydropdown->setEmptyString("There are no categories created yet");
         }
     }
     return new FieldList($categorydropdown, TextField::create('Prefix')->setTitle('Prefix (ie. Dr, Mr, Ms)'), TextField::create('FirstName')->setTitle('First Name'), TextField::create('MiddleName')->setTitle('Middle Name'), TextField::create('LastName')->setTitle('Last Name'), TextField::create('Suffix')->setTitle('Suffix (ie. C.M.)'), TextField::create('JobTitle')->setTitle('Job Title'), EmailField::create('Email'), TextField::create('Phone'), TextField::create('Cell'), TextField::create('Fax'), TextField::create('OfficeLocation')->setTitle('Office Location'), TextField::create('Website')->setTitle('Website (Full URL)'), TextField::create('Facebook')->setTitle('Facebook (Full URL)'), TextField::create('Twitter')->setTitle('Twitter (Full URL)'), $ImageField, HTMLEditorField::create('Bio'));
 }
コード例 #2
0
 public function MoreThanOneStaffCategory()
 {
     if (StaffCategory::get()->count() > 0) {
         return true;
     }
 }
 public function StaffCategory()
 {
     return StaffCategory::get()->byID($this->StaffCategoryID);
 }