I'm trying to add a group of text fields plus some file fields to a ManyManyComplexTableField.
From what I can fathom, I've done the logcal thing (to me), but it fails.
I can get the upload brows boxes to show, but it doesn't upload.
Can anyone see a blunder in this code?
-----
UnitList.php
<?php
class UnitList extends DataObject {
static $db = array(
'UnitNumber' => 'Text',
'UnitType' => 'Text',
'UnitArea' => 'Text',
'UnitRent' => 'Text'
);
static $has_one = array(
'UnitSpec' => 'File',
'UnitLease' => 'File'
);
static $belongs_many_many = array(
'AvailableUnitss' => 'AvailableUnits'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'UnitNumber', 'UnitNumber' ) );
$fields->push( new TextField( 'UnitType', 'Unit Type' ) );
$fields->push( new TextField( 'UnitArea', 'Unit Area' ) );
$fields->push( new TextField( 'UnitRent', 'Unit Rent' ) );
$fields->push( new FileField( 'UnitSpec', 'Unit Specsheet' ) );
$fields->push( new FileField( 'UnitLease', 'Unit Lease Document' ) );
return $fields;
}
}
?>
PropertyPage.php
<?php
/**
* Defines the PropertyPage page type
*/
class PropertyPage extends Page {
static $db = array(
'AvailableSpace' => 'Text',
'UnitSizeRange' => 'Text'
);
static $has_one = array(
);
static $many_many = array(
'AvailableUnits' => 'UnitList'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('AvailableSpace'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('UnitSizeRange'), 'Content');
$Unitstablefield = new ManyManyComplexTableField(
$this,
'AvailableUnits',
'UnitList',
array(
'UnitNumber' => 'UnitNumber',
'UnitType' => 'Unit Type',
'UnitArea' => 'Unit Area',
'UnitRent' => 'Unit Rent',
'UnitSpec' => 'Unit Specsheet',
'UnitLease' => 'Unit Lease Document'
),
'getCMSFields_forPopup'
);
$Unitstablefield->setAddTitle( 'A Unit' );
$Unitstablefield->setPageSize(100);
$fields->addFieldToTab( 'Root.Content.Units', $Unitstablefield );
return $fields;
}
static $icon = "themes/tutorial/images/treeicons/news";
static $defaults = array('ProvideComments' => false);
}
class PropertyPage_Controller extends Page_Controller {
}
?>
Best wishes,
K