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.

Archive /

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

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

DataObjectDecorator and CMSFields...


Reply


2 Posts   1518 Views

Avatar
dio5

Community Member, 501 Posts

23 September 2007 at 11:40pm

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?

Avatar
dio5

Community Member, 501 Posts

24 September 2007 at 2:47am

Found part of my answer on:

http://doc.silverstripe.com/doku.php?id=member&s=checkmember