Advertisement
Guest User

Untitled

a guest
Dec 4th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. class FileGroup extends DataObject{
  4.  
  5.     static $db = array (
  6.         'Title' => 'Varchar(255)'
  7.     );
  8.  
  9.     static $has_one = array (
  10.         'Page' => 'Page'
  11.     );
  12.  
  13.     private static $has_many = array(
  14.         'GroupFiles' => 'GroupFile'
  15.     );
  16.  
  17.     function getCMSFields() {
  18.  
  19.         $fields = FieldList::create(TabSet::create('Root'));
  20.  
  21.         /* -----------------------------------------
  22.          * Files
  23.         ------------------------------------------*/
  24.  
  25.         $config = GridFieldConfig_RecordEditor::create();
  26.         $gridField = new GridField(
  27.             'GroupFiles',
  28.             'Files',
  29.             $this->owner->GroupFiles(),
  30.             $config
  31.         );
  32.         $fields->addFieldToTab('Root.Main', $gridField, 'Content');
  33.  
  34.         return $fields;
  35.  
  36.     }
  37.  
  38. }
  39.  
  40. class GroupFile extends DataObject{
  41.  
  42.     static $db = array ();
  43.  
  44.     private static $has_one = array(
  45.         'FileGroup' => 'FileGroup'
  46.     );
  47.  
  48.     private static $has_many = array(
  49.         'Files' => 'File'
  50.     );
  51.  
  52.     function getCMSFields() {
  53.  
  54.         $fields = FieldList::create(TabSet::create('Root'));
  55.  
  56.         $fields->addFieldToTab('Root.Main', new UploadField('File', 'File for upload'), 'Content');
  57.  
  58.         return $fields;
  59.  
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement