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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

using DataObject::get() to fill dropdown in getCMSFields_forPopup()


Go to End


9 Posts   11107 Views

Avatar
RobertM

Community Member, 26 Posts

24 August 2008 at 10:41am

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?

Go to Top