Hi there, I'm trying to add the DOM functionality to a Frontend Form.
I want to give the logged in User to add some resources that belong to him.
The Resources are simple Dataobjects (in my case Customers, with Name, Address and Description).
Let me show you some code:
// The Member Decorator
class Account extends DataObjectDecorator {
public function extraStatics() {
return array(
'has_many' => array(
'Customers' => 'Customer'
)
);
}
public function getCustomers(){
return $this->owner->Customers();
}
}
// the customer
class Customer extends DataObject {
static $db = array(
'Name' => 'Varchar',
'Address' => 'Text',
'Description' => 'Text'
);
static $has_one = array(
'Account' => 'Member'
);
function getCustomerFields_forPopup(){
return new FieldSet(
new TextField('Name'),
new TextareaField('Address'),
new TextareaField('Description')
);
}
}
// the Page Object with the Form
class CustomersPage extends Page {
}
class CustomersPage_Controller extends Page_Controller {
function init(){
parent::init();
}
function CustomersForm(){
$Manager = new DataObjectManager(
$this,
'Customers',
'Customer',
array('Name' => 'Name'),
'getCustomerFields_forPopup',
'AccountID='.Member::currentUserID()
);
$Manager->setParentClass('Member');
$fields = new FieldSet($Manager);
return new Form($this, 'CustomersForm', $fields, new FieldSet());
}
}
So what happens:
When I open the CustomersPage, I can see the DOM. When Pressing on "Add Customer" not the Popup comes up, but a new site opens with the form that should normaly pop up. Sure, I can add Members there, but they are not associated with the current logged in Member. Instead AccountID shows 0.
So my Question is, what do I have to do, to associate the saved Customer with the Current logged in Member ID and how can I receive the normal DOM behaviour like in the Backend Area with a popping up greybox or facebox or whatever DOM is using?
greetings
andre