Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Trouble adding has_many children

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

Page: 1
Go to End
Author Topic: 564 Views
  • sdc395
    Avatar
    Community Member
    1 Post

    Trouble adding has_many children Link to this post

    Hi all

    Bit of a newbie question, I'm sure, but I just can't find a solution to this problem. I suspect it's something I'm doing wrong but...

    OK, I have a parent class with a has_many relationship with a child class. SilverStripe/Sapphire creates the tables correctly but I'm not able to insert any child objects into the database using SS. The steps I'm expecting to work for me are...

    1. create new Parent object
    2. get Children component set
    3. create Child objects and use add() to add them to Children
    4. call write() on Parent to write Parent and Children to database

    I'm not getting any error messages that I can find but nor am I getting any Child objects inserted into the database. I've done my best to find useful example code, read the documentation, etc. but I'm just stuck.

    Could someone please point me at a complete example of achieving the above or highlight where I'm going wrong?

    Thanks in advance
    Simon

  • moloko_man
    Avatar
    Community Member
    72 Posts

    Re: Trouble adding has_many children Link to this post

    Are you trying to do this on a front end form or in the CMS? I am doing something similar, but I'm trying to build out a front end form that will input the child relationships as well.

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