Hi,
sorry for the late reply.
I have this on my holderpage:
$price_groups = DataObject::get("PriceGroup");
$map = $price_groups ? $price_groups->toDropDownMap("ID", "Value") : array("No Price Groups Available");
$price_table = new ComplexTableField(
$this,
"Prices",
"Price",
array(
"PriceGroupTitle" => "Group",
"Value" => "Value",
"Label" => "Label",
"Price" => "Price"
),
new FieldSet(
new DropdownField("PriceGroupID", "PriceGroup", $map),
new TextField("Value"),
new TextField("Label"),
new TextField("Price")
),
"",
"PriceGroupID ASC, Value ASC, Price ASC"
);
$price_table->setPageSize(50);
$fields->addFieldToTab('Root.Content.PriceTable', $price_table);
And this in my Price class:
<?php
class Price extends DataObject{
static $db = array(
"Value" => "Varchar(200)",
"Label" => "Varchar",
"Price" => "Varchar"
);
static $has_one = array(
"PricelistPage" => "PricelistPage",
"PriceGroup" => "PriceGroup"
);
function getPriceGroupTitle()
{
$g = DataObject::get_by_id("PriceGroup", $this->PriceGroupID);
return $g ? $g->Value : "No group selected";;
}
}
Hope this helps.