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   1204 Views

Avatar
teejay

Community Member, 63 Posts

25 January 2010 at 11:48pm

Edited: 25/01/2010 11:49pm

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

Community Member, 254 Posts

11 February 2010 at 2:20pm

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

Community Member, 63 Posts

11 February 2010 at 2:30pm

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

Avatar
Ingo

Forum Moderator, 801 Posts

21 February 2010 at 7:17pm

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