Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Nested DOM doesn´t work in ModelAdmin

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 479 Views
  • Bereusei
    Avatar
    Community Member
    94 Posts

    Nested DOM doesn´t work in ModelAdmin Link to this post

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

    }

  • Bereusei
    Avatar
    Community Member
    94 Posts

    Re: Nested DOM doesn´t work in ModelAdmin Link to this post

    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.

    479 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.