Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Label Error with $tablefield

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

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

Page: 1
Go to End
Author Topic: 1662 Views
  • 2Fast4UeXtrem
    Avatar
    Community Member
    3 Posts

    Label Error with $tablefield Link to this post

    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

  • 2Fast4UeXtrem
    Avatar
    Community Member
    3 Posts

    Re: Label Error with $tablefield Link to this post

    Is it allowed to upper topics unanswered ???

  • UncleCheese
    Avatar
    4085 Posts

    Re: Label Error with $tablefield Link to this post

    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.

  • 2Fast4UeXtrem
    Avatar
    Community Member
    3 Posts

    Re: Label Error with $tablefield Link to this post

    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)

    1662 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.