Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » using DataObject::get() to fill dropdown in getCMSFields_forPopup()

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 8140 Views
  • RobertM
    Avatar
    Community Member
    26 Posts

    Re: using DataObject::get() to fill dropdown in getCMSFields_forPopup() Link to this post

    Actually, I have noticed on closer inspection that the dropdown field are indeed saving to the database, however the managers name is not displaying in the HasManyComplexTableField,

    <?php
    /**
    * Defines the ProjectHolder page type
    */
    class ProjectHolder extends Page {
    static $db = array(
    );
    static $has_one = array(

    );
    static $has_many = array(
    'Projects' => 'Project',
       'Managers' => 'Manager'
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();

       $tablefield = new HasManyComplexTableField(
    $this,
    'Projects',
    'Project',
    array(
        'title' => 'Title',
        'Manager' => 'Manager'
    ),
    'getCMSFields_forPopup'
    );
    $tablefield->setAddTitle( 'A Project' );

       $managertablefield = new HasManyComplexTableField(
    $this,
    'Managers',
    'Manager',
    array(
        'name' => 'Name',
       
    ),
    'getCMSFields_forPopup'
    );
    $managertablefield->setAddTitle( 'A Manager' );

       $fields->addFieldToTab( 'Root.Content.Projects', $tablefield );
       $fields->addFieldToTab( 'Root.Content.Managers', $managertablefield );
    return $fields;
    }
    }

    class ProjectHolder_Controller extends Page_Controller {
    }
    ?>

    I notice that having

    $tablefield = new HasManyComplexTableField(
    $this,
    'Projects',
    'Project',
    array(
        'title' => 'Title',
        'ManagerID' => 'Manager'
    ),


    displays the Id no in the table, but is there a way to get it to display the saved manager's name?

    8140 Views
Page: 1 2
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.