diff --git a/code/model/BlogPost.php b/code/model/BlogPost.php index 7e98f2f..2eeb2a2 100644 --- a/code/model/BlogPost.php +++ b/code/model/BlogPost.php @@ -216,7 +216,7 @@ class BlogPost extends Page $authorField = ListboxField::create( 'Authors', _t('BlogPost.Authors', 'Authors'), - $this->getCandidateAuthors()->map()->toArray() + $self->getCandidateAuthors()->map()->toArray() )->setMultiple(true); $authorNames = TextField::create( diff --git a/tests/BlogPostTest.php b/tests/BlogPostTest.php index 6b10635..fd7b575 100644 --- a/tests/BlogPostTest.php +++ b/tests/BlogPostTest.php @@ -78,5 +78,9 @@ class BlogPostTest extends SapphireTest Config::inst()->update('BlogPost', 'restrict_authors_to_group', 'BlogUsers'); $this->assertEquals(3, $blogpost->getCandidateAuthors()->count()); + + // Test cms field is generated + $fields = $blogpost->getCMSFields(); + $this->assertNotEmpty($fields->dataFieldByName('Authors')); } }