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.

Archive /

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

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

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


Go to End
Reply


9 Posts   8213 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