Jump to:

3448 Posts in 1062 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Issue with has_many

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

Page: 1
Go to End
Author Topic: 1151 Views
  • teejay
    Community Member
    63 Posts

    Issue with has_many Link to this post

    I have got a small issue with the has_many relation. I just make it short and I hope it is enough to follow

    class1 extends userdefinedform

    has_many -> 'TeamPages' => 'Class2'

    class2 extends Page

    has_one -> 'Team' => 'Class1'

    now i add a hasmanycomplextablefield

    function getCMSFields() {
          $fields = parent::getCMSFields();
          $tablefield = new HasManyComplexTableField(
                      'Title' => 'Name',
                      'Email' => 'Email',
                      'PhoneNumber' => 'Phone'
          $fields->addFieldToTab( 'Root.Content.AddTeamMember', $tablefield );

          return $fields;

    Now the issue. I have created a template for class1 and tryed to access TeamPages. I have checked my entries in the complex table so that something comes back when I do <% control TeamPages %>. But it didnt. Then i updated one entry inside (or outside) of the complex table and now the entry is visible in my template. I flush(all) all the time so there should not be the issue. Can anyone confirm that ?? Ah I use the latest version 2.3.5

    Thx for every hint or answer

  • Bambii7
    Community Member
    254 Posts

    Re: Issue with has_many Link to this post

    hey teejay,
    I'm no guru but if class1 extends userdefinedform I don't think you can <% control TeamPages %>, isn't that only Viewable data?
    I don't really understand the issue that well. You tried controlling a relationship without data entries, then you added some data, then the info showed, and you flush all the time. What to you need confirmation on?
    I think I might be wrong about the userdefinedform I guess it is viewable data....

  • teejay
    Community Member
    63 Posts

    Re: Issue with has_many Link to this post

    Nope you are wrong UserDefinedForm extends Page. This is just a very strange issue and I have atm no explanation for it.

  • Ingo
    Forum Moderator
    801 Posts

    Re: Issue with has_many Link to this post

    ManyManyCTF has a similar issue: http://open.silverstripe.org/ticket/4706

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.