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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Nested DOM doesn´t work in ModelAdmin


Go to End


2 Posts   974 Views

Avatar
Bereusei

Community Member, 96 Posts

16 January 2012 at 8:52am

Edited: 16/01/2012 9:18am

Hi everyone,

does someone know about problems with nested DOMs and the ModelAdmin? I like the nested DOM solution from UncleCheese:
http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/nested-dataobjectmanager-a-dom-in-a-dom/

So I´ve created an normal DataObject with a nested DOM.

I can create an entry on a page in the sitetree using nested DOMs, but the same doesn´t work in the ModelAdmin.
If I click on 'Add DataObject', I get the right form from the regular DOM but also an list with all nested DOM entries
instead of the message 'You may add 'dataobjectname' once you have saved for the first time.'

Further, I can create an entry and it is shown in the list in ModelAdmin, but neighter on the frontend-page nor on the page in the sitetree (in backend) it is listed. That´s very wired, because everything works, if I create an entry via the page in the sitetree.

Hier is my code:
class Workshop extends DataObject
{
//db fields
static $db = array (
'Datum' => 'Date',
'Text' => 'Varchar(255)',
'Trainer' => 'Varchar(255)',
'Kosten' => 'Varchar(255)',
'Status' => 'Varchar(255)'
);

//Relations
static $has_one = array (
'WorkshopPage' => 'WorkshopPage'
);

static $has_many = array (
'Workshoptrainingsstunden' => 'Workshoptraining'
);

//Fields to show in the DOM table
static $summary_fields = array(
'Datum',
'Text',
'Trainer'
);

static $default_sort = "Datum ASC";

function IsAuthor() {
$member = Member::currentUserID();
$Anmeldung = DataObject::get('WorkshopAnmeldung');
return ($member == $Anmeldung->AuthorID);
}

//Fields for the DOM Popup
public function getCMSFields()
{
return new FieldSet(
new DateField('Datum'),
new TextField('Text'),
new TextField('Trainer'),
new TextAreaField('Kosten'),
new DataObjectManager(
$this,
'Workshoptrainingsstunden',
'Workshoptraining',
array('Type' => 'Type')
)

);

}

class WorkshopAnmeldung extends DataObject
{
//db fields
static $db = array (
'Datum' => 'Date',
'Workshops' => 'Varchar(255)',
'Type' => 'Varchar(255)',
'Teilnehmer' => 'Varchar(255)'
);

//Relations
static $has_one = array (
'WorkshopPage' => 'WorkshopPage'
);

//Fields to show in the DOM table
static $summary_fields = array(
'Datum',
'Workshops',
'Type',
'Teilnehmer'
);

static $default_sort = "Datum ASC";

//Fields for the DOM Popup
public function getCMSFields()
{
return new FieldSet(
new DateField('Datum'),
new TextField('Workshops'),
new TextField('Type'),
new TextField('Teilnehmer')
);

}

Avatar
Bereusei

Community Member, 96 Posts

16 January 2012 at 9:14am

To make it more puzzling:
On another page I´ve used an DataObjectSet to show the entries of one DataObject and the other DataObject (Workshops) with the nested DOM - On this page the entries, I´ve created with the ModelAdmin, are listed in the list on frontend-page.
BUT anyway on the regular (frontend)-page (Workshops) these entries aren´t listed.