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   612 Views

Avatar
danzzz

Community Member, 175 Posts

5 July 2011 at 5:51am

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

4085 Posts

5 July 2011 at 6:03am

FaqGroup.groupname doesn't work?

Avatar
danzzz

Community Member, 175 Posts

5 July 2011 at 6:11am

Edited: 05/07/2011 6:11am

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

Community Member, 175 Posts

5 July 2011 at 8:33am

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