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

Label Error with $tablefield


Reply


4 Posts   1705 Views

Avatar
2Fast4UeXtrem

Community Member, 3 Posts

24 June 2008 at 10:04pm

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(
         $this,
         'MyReferences',
         'Referenzen',
         array(
            'Ersteller'=>'Ersteller_label',
            'Kollektorart'=>'Kollektorart_label',
            'Gebaeudeart' => 'Gebaeudeart_label',
            'Dachtyp' => 'Dachtyp_label',
            'Anlagengroesse' => 'Anlagengroesse_label',
         ),
         'getCMSFields_forPopup'
      );
      $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 :)

Greetings,
BennY from .De

Avatar
2Fast4UeXtrem

Community Member, 3 Posts

30 June 2008 at 10:19pm

Is it allowed to upper topics unanswered ???

Avatar
UncleCheese

Forum Moderator, 4096 Posts

1 July 2008 at 3:02am

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.

Avatar
2Fast4UeXtrem

Community Member, 3 Posts

7 July 2008 at 10:36pm

Edited: 07/07/2008 10:37pm

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)