Jump to:

3433 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » GridFieldConfig_RelationEditor doesn`t work with upload photo

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 230 Views
  • skv_gwww
    Avatar
    Community Member
    1 Post

    GridFieldConfig_RelationEditor doesn`t work with upload photo Link to this post

    Hi, i`m a silverstripe beginner.
    I need to do some kind of gallery catalog, so i decided to make it with GridFieldConfig_RelationEditor

    1 girl can have many photos and can belong to one gallery
    1 gallery can have many girls

    Here is my problem:

    ##mysyte/code/Girl.php

    <?php
    class Girl extends DataObject {
    private static $db = array(
    'Name' => 'Varchar',
    'Description' => 'Varchar',
    );
    private static $has_one = array(
    'Gallery' => 'Gallery'
    );
    /*
    private static $has_many = array(
    'Photo' => 'Image'
    );
    */
    public function getCMSFields() {
    $fields = parent::getCMSFields();
    //$fields->addFieldToTab('Root.Photo', new UploadField('Photo'));
    return $fields;
    }
    }

    ##mysyte/code/Gallery.php
    <?php
    class Gallery extends Page {
    private static $has_many = array(
    'Girls' => 'Girl'
    );

    public function getCMSFields() {
    $fields = parent::getCMSFields();
    $config = GridFieldConfig_RelationEditor::create();
    $girlsField = new GridField(
    'Name', // Field name
    'Girl', // Field title
    $this->Girls(),
    $config
    );

    // Create a tab named "Girls" and add our field to it
    $fields->addFieldToTab('Root.Girls', $girlsField);
    return $fields;
    }

    }
    class Gallery_Controller extends Page_Controller {
    }

    This code works fine, but when i`m uncomenting parts with uploading images in Girl.php file,
    my code doesn`t work.
    Does any body knows where is the problem? Thank you.

    230 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.