Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObjectManager usage in frontend form

Go to End

3 Posts   1832 Views


Community Member, 146 Posts

4 March 2011 at 8:54am

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(){

        function CustomersForm(){
            $Manager = new DataObjectManager(
                    array('Name' => 'Name'),
            $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?




Community Member, 146 Posts

17 March 2011 at 5:05am

Hi, I know it's been a while since opening of this thread, but I will try to wake it up again in hope, some may have an idea now, how to solve this Problem.




Community Member, 4 Posts

5 April 2011 at 8:21pm

Hi Andre,

why your Add action opens in another window, I don't know, in my case it just happens as expected. As to why the new record does not get associated with the CurrentMember, I just hit the same problem... The solution was a call to setSourceID() as follows:


HTH, cheers,