17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1019 Views |
-
dataObject relationships

15 August 2008 at 10:02pm
I have created a page with a 1-many dataObject storing the names of a project and who is responsible. I need to create another 1-many table, so that inside the popup when adding a new record there is a drop down menu to select which person. I don't want to create a page for each person, like it does in the tutorial. Can onyone help?
-
Re: dataObject relationships

16 August 2008 at 4:53am
Hi,
Not sure to get you right
You mean adding a record in the projects table?
Take a look at this code.class Person extends DataObject {
[...]
}class Project extends DataObject {
static $has_one = array(
'Responsible' => 'Person'
);function getCMSFields_forPopup() {
$fields = new FieldSet();
$mySet1 = DataObject::get('Person');
$map1 = $mySet1 ? $mySet1->toDropDownMap('ID', 'Name') : '';
$fields->push(new DropdownField('ResponsibleID',
'Grupo',
$map1
));
return $fields;
}[...]
}class ProjectHolder extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();
$projectstable = new ComplexTableField(
$this,
'Projects ', //Relation Name that doesn't exists
'Project ',
array(
'ProjectName' => 'ProjectName',
'Responsible.Name' => 'Responsible'
),
'getCMSFields_forPopup'
);
$projectstable ->setParentClass(false);
$fields->push($projectstable);
}Did it help?
| 1019 Views | ||
|
Page:
1
|
Go to Top |

