Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » CMS edit has_one related object's data in same popup

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

Page: 1
Go to End
Author Topic: 379 Views
  • ismooth
    Community Member
    22 Posts

    CMS edit has_one related object's data in same popup Link to this post


    I have two objects, say:

    class MyObjA extends DataObject {
    has_one = array('objB' => 'MyObjB');

    class MyObjB extends DataObject {
    has_many = array('objsA' => 'MyObjA');

    what I woul like to be able is when in CMS popup editing MyObjA, to have additional tab with loaded MyObjB with all it's data. I tried doing this in MyObjA:

    function getCMSFields(){
    $f = parent::getCMSFields();
    $f->addFieldsToTab('Root.objB', $this->objB()->getCMSFields());
    return $f;

    but all I get is bunch of empty fields. I also tried explicitly fetching related object by it's ID, but same result.
    Is there a way to have in the same popup an object and it's has_one related object, so that I can edit them both (not edit the relation, but their data) at the same time?

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.