Jump to:

3429 Posts in 1057 Topics by 734 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: 1141 Views
  • teejay
    Avatar
    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(
                $this,
                'TeamPages',
                'Class2',
                array(
                      'Title' => 'Name',
                      'Email' => 'Email',
                      'PhoneNumber' => 'Phone'
                ),
                'getCMSFields_forPopup'
          );
          $tablefield->setParentClass('Class1');
          
          $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
    Thomas

  • Bambii7
    Avatar
    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
    Avatar
    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
    Avatar
    Forum Moderator
    801 Posts

    Re: Issue with has_many Link to this post

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

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