Hi I'm getting the Error Saving Content on a page with a HasManyComplexTableField. I can't get to the error and have flushed DB and reviewed syntax 10 times, has anyone a hint on this ? Error gets away when I comment out the HasManyComplexTableField in ConfigPage ?
Thanks guys
=======UPDATE : ERROR FOUND : typo as usual - code below is now correct ====
mysite/code/ConfigPage.php
<?php
class ConfigPage extends Page {
static $icon = "tutorial/images/treeicons/news";
static $db = array(
);
static $has_one = array( 'Photo1' => 'Image' );
static $has_many = array(
'Customers' => 'Customer'
);
static $defaults = array( 'ShowInMenus' => false);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('Photo1'), 'Content');
$tablefield = new HasManyComplexTableField(
$this,
'Customers',
'Customer',
array(
'Name' => 'Name',
'Description' => 'Description',
'Url' => 'Url'
),
'getCMSFields_forPopup'
);
$tablefield->setParentClass('ConfigPage');
$tablefield->setAddTitle( 'Customer' );
$fields->addFieldToTab( 'Root.Content.Customer', $tablefield );
return $fields;
}
}
class ConfigPage_Controller extends ContentController {
function init() {
parent::init();
}
}
?>
mysite/code/Customer.php
<?
class Customer extends DataObject {
static $db = array(
'Name' => 'Text',
'Description' => 'Text',
'Url' => 'Text'
);
static $has_one = array(
'MyConfig' => 'ConfigPage'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Name' ) );
$fields->push( new TextField( 'Description' ) );
$fields->push( new TextField( 'Url' ) );
return $fields;
}
}?>