Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjects Overview Page + Column from a has_one


Reply

4 Posts   607 Views

Avatar
danzzz

5 July 2011 at 5:51am Community Member, 175 Posts

hi,

I have this DO's:

Faq.php

class Faq extends DataObject {
...
static $has_one = array(
   'FaqPage' => 'FaqPage',
   'FaqGroup' => 'FaqGroup'
);

FaqGroup.php

class FaqGroup extends DataObject {

static $db = array(
   'groupname' => 'Varchar(255)'
);

static $has_many = array(
   'Faqs' => 'Faq'
...

and this Page:

FaqPage.php

class FaqPage extends Page {
...
static $has_many = array(
    'Faqs' => 'Faq'
   );

the DOM Code:

$f->addFieldToTab("Root.Content.FAQ", new DataObjectManager(
      $this,
      'Faqs',
      'Faq',
      array(
         'question' => 'Frage',
         'answer' => 'Antwort',
         'active' => 'Aktiv?',
      ),
      'getCMSFields_forPopup'
   ));

As you see there are 3 columns for the overview. I need a 4th column with the FaqGroup (groupname), how to do that?

thx

Avatar
UncleCheese

5 July 2011 at 6:03am 4085 Posts

FaqGroup.groupname doesn't work?

Avatar
danzzz

5 July 2011 at 6:11am (Last edited: 5 July 2011 6:11am), Community Member, 175 Posts

...
$f->addFieldToTab("Root.Content.FAQ", new DataObjectManager(
      $this,
      'Faqs',
      'Faq',
      array(
         'question' => 'Frage',
         'answer' => 'Antwort',
         'active' => 'Aktiv?',
         'FaqGroup.groupname' => 'Gruppe'
      ),
      'getCMSFields_forPopup'
   ));
...

no, dont work for me - the column in the overvie is empty ...

Avatar
danzzz

5 July 2011 at 8:33am Community Member, 175 Posts

sorry, it's working now - after re-saving the DO it's shows the groupname :-)