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')
);
}