Jump to:

23493 Posts in 19013 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [Solved] Changing the classname when saving?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 414 Views
  • esakrielaart
    Avatar
    Community Member
    56 Posts

    [Solved] Changing the classname when saving? Link to this post

    Hi all,

    I have a Class which is extended a few times, now when I use GridField, I use this to add a new holder for this class. Next, I wish the user to select one of the childclasses, as depending on that choice, the fields in the CMS should change to the proper CMSFields (using the corresponding getCMSFields()), however I receive errors at line x of core/Object.php when I simply put $this->class = [selected classname] in my onBeforeWrite. Am I missing some more clever feature of silverstripe to fix this, or is it not possible to change the classname of an object during save? I noticed Object->class is public, so I should just be allowed to overwrite this property right?

    Friendly regards,
    Maurice

  • esakrielaart
    Avatar
    Community Member
    56 Posts

    Re: [Solved] Changing the classname when saving? Link to this post

    Never mind, overlooked the DataObject->setClassName(string) method.

    Regards,

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