Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » SimpleTreeDropdownField value not saved

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: 1098 Views
  • k0m0r
    Avatar
    Community Member
    39 Posts

    SimpleTreeDropdownField value not saved Link to this post

    Hi there.
    I encountered a following problem with SimpleTreeDropdownField.
    I have a following structure:

    1. FaqList page with collection of FaqItem data objects (managed by DOM).
    2. Each FaqItem may contain many RelatedItem data objects (managed by DOM in pop-up - this works fine).
    3. Each RelatedItem pop-up has a SimpleTreeDropdownField.

    Now, when I create a new FaqItem, save it, and then add a RelatedItem, everything works fine.
    I can save and display (in CMS and online) all the values except for the 'LinkToRelated' field.
    The SimpleTreeDropdownField value simply isn't saved.
    Even in CMS, after saving the RelatedItem popup - I can see that the select value goes back to the empty line ('select a page').

    Any idea what's wrong?

    Here is a piece of code:

    class FaqList extends Page {

    public static $db = array(
    );

    public static $has_many = array(
    "Items" => "FaqItem",
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();   
    $manager = new DataObjectManager(
    $this,
    'Items',
    'FaqItem',
    array('Title' => 'Title'),
    'getCMSFields_forPopup'
    );
    $fields->addFieldToTab('Root.Content.Items',$manager);      
    return $fields;
    }
    }

    class FaqItem extends DataObject {

    public static $db = array(
    );

    public static $has_one = array(
    "FaqList" => "FaqList",
    );

    public static $has_many = array(
    "RelatedItems" => "RelatedItem",
    );

    function getCMSFields_forPopup() {
    $fields = new FieldSet();
    $manager = new DataObjectManager(
    $this,
    'RelatedItems',
    'RelatedItem',
    array('Title' => 'Title'),
    'getCMSFields_forPopup'
    );
    $fields->push($manager);      
    return $fields;
    }
    }

    class RelatedItem extends DataObject {

    public static $db = array(
    );

    public static $has_one = array(
    "ItemParent" => "DataObject",
    "LinkToRelated" => "SiteTree",
    );

    function getCMSFields_forPopup() {
    $fields = new FieldSet();
    $dropdown = new SimpleTreeDropdownField('LinkToRelated','Link to page','SiteTree');
    $dropdown->setEmptyString('-- Select a page --');
    $fields->push($dropdown);
    return $fields;
    }   
    }

  • UncleCheese
    Avatar
    4085 Posts

    Re: SimpleTreeDropdownField value not saved Link to this post

    $dropdown = new SimpleTreeDropdownField('LinkToRelatedID','Link to page','SiteTree');

  • k0m0r
    Avatar
    Community Member
    39 Posts

    Re: SimpleTreeDropdownField value not saved Link to this post

    Thank You very much, I knew I overlooked something

    1098 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.