Jump to:

3450 Posts in 1063 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Edit a field in image-table from within another page or dataobject

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

Page: 1
Go to End
Author Topic: 614 Views
  • theAlien
    Avatar
    Community Member
    131 Posts

    Edit a field in image-table from within another page or dataobject Link to this post

    Hi,
    I have the following structure:

    class SomePage extends Page {
       static $has_one => array(
          'SomeImages'   => 'SomeImage'
       );
       static $has_many => array(
          'SomeDataObjects'   => 'SomeDataObject'
       );
    }
    ...

    class SomeDataObject extends DataObject {
       static $has_one => array(
          'SomePages'   => 'SomePage',
          'SomeImages'   => 'SomeImage'
       );
    }

    class SomeImage extends DataObjectDecorator {
       function extraStatics() {
          return array(
             'db' => array(
                'Copyright'   => 'Varchar(50)'
             )
          );
       }
    }

    Since copyrights directly belong to one specific image, and since they should be set ideally together with uploading an image (either related to SomePage or SomeDataObject, that shouldn't matter), I would like to create a TextField in SomePage and SomeDataObject that writes and gets it's values directly to and from the Copyright db-field in SomeImage.

    My question: is this possible and how...?

    614 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.