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.

Data Model Questions

Issue with has_many


Reply

4 Posts   1160 Views

Avatar
teejay

25 January 2010 at 11:48pm (Last edited: 25 January 2010 11:49pm), Community Member, 63 Posts

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

Avatar
Bambii7

11 February 2010 at 2:20pm Community Member, 254 Posts

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

Avatar
teejay

11 February 2010 at 2:30pm Community Member, 63 Posts

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

Avatar
Ingo

21 February 2010 at 7:17pm Forum Moderator, 801 Posts

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