Version: current

     1 <?php
     2
     3 class PhotoAlbumItem extends DataObject
     4 {
     5     static $db = array (
     6         'Caption' => 'Text'
     7     );
     8
     9     static $has_one = array (
    10         'Album' => 'PhotoAlbumPage',
    11         'Gallery' => 'PhotoGalleryPage',
    12         'Image' => 'Image',
    13     );
    14
    15     function onBeforeWrite() {
    16         parent::onBeforeWrite();
    17
    18         $this->GalleryID = $this->Album()->ParentID;
    19     }
    20
    21     function CropImages() {
    22         return $this->Gallery()->CropImages;
    23     }
    24
    25     public function getCMSFields_forPopup() {
    26         $fields = new FieldSet();
    27         $fields->push(new TextareaField('Caption', $this->fieldLabel('Caption') /* _t('PhotoAlbumItem.Caption','Caption')*/));
    28         $fields->push(new ImageField('Image', $this->fieldLabel('Image')));
    29
    30         return $fields;
    31     }
    32
    33     function ParentObject() {
    34         return $this->Album();
    35     }
    36 }
    37
    38

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -