Hi Folks,
I have a form which will submit a dataobject from the front end, adapted from the nice tutorial found here, and also using the DataObjets as Pages module:
http://www.ssbits.com/tutorials/2012/s-new-post-78/
I am using SS3, everything is working nicely, it's very cool and I can submit products. The problem is I am now trying to associate that DataObject with the logged in user, and also be able to generate a list of items submitted by the user. So what I have done:
In 'Product.php':
class Product extends DataObjectAsPage
{
static $has_one = array(
"Member" => "Member"
);
Then I add a extension to the Member (and register it in config) as follows:
class MyMember extends DataExtension {
static $has_many = array(
"Products" => "Product"
);
Then in my form I have:
$owner=Member::currentUserID();
// form fields
$fields = new FieldList(
new TextField('Title', 'Title :'),
new HtmlEditorField('Content', 'Content:'),
new HiddenField('Member', '', $owner),
);
All I can see is Product table does have a new "MemberID" field, but no data :0(
I can't see anything in the Member table that is different either. Also I am lost as to how to retrieve Products by user if in fact I had the relationship working in the first place.
So in a nutshell: associate DataObjects with a Member, generate a list of their DataObjects. Any pointers would be GREATLY appreciated.
Disclaimer: I probably just have no idea what I am doing.
Thanks