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.


Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Label Error with $tablefield


4 Posts   1672 Views


24 June 2008 at 10:04pm Community Member, 3 Posts

Hello Everyone...

I got the following Code from a tut in a german magazine, but rechecked it with the tut on this site // by an admin in the irc... Perhaps any Forum User can find the mistake i did...

Heres the Code for my HasManyComplexTableField:

class Referenz extends Page {

   static $has_many = array(
      'MyReferences' => 'Referenzen'

   function getCMSFields() {

      $fields = parent::getCMSFields();

      $tablefield = new HasManyComplexTableField(
            'Gebaeudeart' => 'Gebaeudeart_label',
            'Dachtyp' => 'Dachtyp_label',
            'Anlagengroesse' => 'Anlagengroesse_label',
      $tablefield->setAddTitle( 'a Reference' );

   $fields -> addFieldToTab("Root.Content.Referenzen", $tablefield);
   return $fields;


What it looks like is this:

Perhaps anyone can tell me, why there is just the first COlum labeled ["Ersteller"] and the others not... Okay, bad engloish for bad guys like me ^^

Would be happy if someone can help me out :)

BennY from .De


30 June 2008 at 10:19pm Community Member, 3 Posts

Is it allowed to upper topics unanswered ???


1 July 2008 at 3:02am 4085 Posts

Can you show us the Referenzen object?

I almost wonder if you accidentally got some HTML in your data that is breaking the table. Seems very odd.


7 July 2008 at 10:36pm (Last edited: 7 July 2008 10:37pm), Community Member, 3 Posts

Hopefully you mean the REFERENCEN.php ?

Here it is, the Names are german stuff, don't meantion it...

class Referenzen extends DataObject {

   static $db = array(
      'Ersteller' => 'Text',
      'Kollektorart' => 'Text',
      'Gebaeudeart' => 'Text',
      'Dachtyp' => 'Text',
      'Anlagengroesse' => 'Text',
      'Standort' => 'Text',
      'Stadt' => 'Text',
      'Ertrag' => 'Text',

   static $has_one = array(
      'Image' => 'Image',
      'MyMyReferences' => 'Referenz'

   function getCMSFields_forPopup() {

      $fields = new FieldSet();
      $fields -> push( new TextField('Ersteller'));
      $fields -> push( new DropdownField('Kollektorart','Kollektorart',singleton('Dropdown1')->dbObject('Kollektorart')->enumValues()));
      $fields -> push( new DropdownField('Gebaeudeart','Gebaeudeart',singleton('Dropdown2')->dbObject('Gebaeudeart')->enumValues()));
      $fields -> push( new DropdownField('Dachtyp','Dachtyp',singleton('Dropdown3')->dbObject('Dachtyp')->enumValues()));
      $fields -> push( new DropdownField('Anlagengroesse','Anlagengroesse',singleton('Dropdown4')->dbObject('Anlagengroesse')->enumValues()));
      $fields -> push( new DropdownField('Standort','Standort',singleton('Dropdown5')->dbObject('Standort')->enumValues()));
      $fields -> push( new TextField('Stadt'));
      $fields -> push( new TextField('Ertrag'));
      $fields -> push( new ImageField('Image'));
      return $fields;



class Dropdown1 extends DataObject {
static $db = array(
'Kollektorart' => "Enum('Standart-Kollektor,Schrägschnitt-Kollektor,Aufgeständerter Kollektor,Solardach Plus (mit PV),Schwimmbadheizung','Standart-Kollektor')"

class Dropdown2 extends DataObject {
static $db = array(
'Gebaeudeart' => "Enum('Einfamilienhaus,Mehrfamilienhaus,öffentliche Gebäude,Gewerbliche Gebäude,Landwirtschaftliche Anwesen,Denkmalgeschützte Gebäude,Sonstige Gebäude','Einfamilienhaus')"

class Dropdown3 extends DataObject {
static $db = array(
'Dachtyp' => "Enum('Ziegel rot,Ziegel dunkel,Schiefer,Sonstige','Ziegel rot')"

class Dropdown4 extends DataObject {
static $db = array(
'Anlagengroesse' => "Enum('bis 20m²,bis 30m²,bis 40m²,größer als 40m²','bis 20m²')"

class Dropdown5 extends DataObject {
static $db = array(
'Standort' => "Enum('Luxemburg,Deutschland,Belgien','Deutschland')"

I also get a getReferences Function within the Reference.php, there is HTML in use, but can this have an effect of the tablefield? it was the same 'error' just before i added HTMl content :) (btw getReferences builds a form)