Hi
I have a class NewRelease that extends DataObject with a $has_one to a Page:
static $db = array('Artist' => 'Varchar(64)');
static $has_one = array(
'Page' => 'NewsPage',
);
And a Page with a $has_many to NewRelease:
static $has_many = array(
'NewReleases' => 'NewRelease'
);
I also have $fields->removeByName('Page') in the getCMSFields function of NewRelease. I don't want the CMS user to have to select 'News' from a droop down field to create the relationship.
Whenever I create and save a new 'NewRelease' and then do
<% control NewReleases %>
$Artist
<% end_control %>
in my NewPage.ss template, I am not getting any results
I am extending ModelAdmin to handle the NewRelease DataObject organization and therefore don't have a getCMSFields function for NewRelease represented in NewsPage.php. Could this be causing the problem?
My second question is, as a work around, I have created a public function Releases() { return DataObject::get('NewRelease', null, null, null, 6); } to pull the NewReleases into NewsPage.ss:
<% control Releases %>
$Artist
<% end_control %>
Is this a bad solution since I still notice there is no NewsPageID being created on NewRelease and therefore no relationship being formed in the database.
Thanks in advance. This has been driving me crazy!