Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjects Overview Page + Column from a has_one

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 528 Views
  • danzzz
    Avatar
    Community Member
    175 Posts

    DataObjects Overview Page + Column from a has_one Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjects Overview Page + Column from a has_one Link to this post

    FaqGroup.groupname doesn't work?

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: DataObjects Overview Page + Column from a has_one Link to this post

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

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: DataObjects Overview Page + Column from a has_one Link to this post

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

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