Hello
Using SS 3.0.0-alpha-1 I am trying to link a page with its author:
class AuthorPage extends Page {
public static $has_one = array (
'Author' => 'Member'
);
protected function onBeforeWrite () {
$this->Author = Member::currentUser ();
parent::onBeforeWrite ();
}
}
When I add an AuthorPage in the CMS with the "add new" dialogue, I get the following error message:
---
[User Error] Couldn't run query: INSERT INTO "AuthorPage" ("ID") VALUES (17) Cannot add or update a child row: a foreign key constraint fails ("silverstripe"."authorpage", CONSTRAINT "authorpage_ibfk_1" FOREIGN KEY ("AuthorID") REFERENCES "Member" ("ID"))
POST /admin/pages/AddForm
Line 562 in /Users/georg/silverstripe/sapphire/model/MySQLDatabase.php
---
The error message is the same if the onBeforeWrite () function is missing in AuthorPage.
What am I doing wrong here?
Thanks for your hints.
gh