Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DataObjectDecorator and CMSFields...

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1488 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    DataObjectDecorator and CMSFields... Link to this post

    Ok I've found out that when I want to add fields to my member table, I should use DataObjectDecorator.

    I also found out that

    DataObject::add_extension('Member', 'MyExtensionOfMember');

    belongs in _config.php (please add this to http://doc.silverstripe.com/doku.php?id=dataobjectdecorator, wasn't obvious at all to me, but maybe I'm stupid)

    Now I have:

    class PhotoMemberRole extends DataObjectDecorator
    {
       function extraDBFields()
       {
          return array(
             'db' => array(
                'Website' => 'Varchar',
    'City' => 'Varchar',
    'PostalCode' => 'Int'
             )
          );
       }
    }

    Now how do I add those fields to my cms? Could I just use the regular function getCMSFields() for it?

    Q2: why would I need augmentDatabase()? Does it do anything else than adding fields like extraDBFields()? It probably does, but then, why do I need to use them BOTH like the forum does?

  • dio5
    Avatar
    Community Member
    501 Posts
    1488 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.