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

error saving content on HasManyComplexTableField


Reply

672 Views

Avatar
erwanpia

29 September 2008 at 8:53pm (Last edited: 29 September 2008 8:55pm), Community Member, 63 Posts

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;
}

}?>