Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » How to implement on a dataobjectdecorator?[solved sort of]

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 477 Views
  • cumquat
    Avatar
    Community Member
    189 Posts

    How to implement on a dataobjectdecorator?[solved sort of] Link to this post

    Hi there,

    I'm using Uncle Cheeses Mappable module and so far so good it works great for me on new dataobjects,

    class POI extends DataObject implements Mappable {

    - this all works great

    that i have but what i want to do now is to implement it on the databojectdecorator im using for the members table and when i try with the code below the site just gives a 500 error so im guessing that im using the wrong syntax.

    class MemberTeamExtension extends DataObjectDecorator implements Mappable {

    - this doesn't

    Any pointers?

    regards

    Mick

  • cumquat
    Avatar
    Community Member
    189 Posts
  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: How to implement on a dataobjectdecorator?[solved sort of] Link to this post

    What is the actual error message? (turn on dev mode or check your php error log)

  • cumquat
    Avatar
    Community Member
    189 Posts

    Re: How to implement on a dataobjectdecorator?[solved sort of] Link to this post

    Hi Willr

    Thanks for responding, the site is in dev mode but alas i'm getting no errors at all apart from just http 500 error no log files or anything. In firefox with firebug there is nothing either, below is the code for the php page, if i remove the implements mappable it works fine?

    class MemberTeamExtension extends DataObjectDecorator implements Mappable {

       public function extraStatics() {
          return array (
             'db' => array (
                'DOB' => 'Date',
                'Address' => 'Varchar',
                'Town' => 'Varchar',
                'Postcode' => 'Varchar',
                'DefaultNum' => 'Varchar',
                'HomeNum' => 'Varchar',
                'OtherNum' => 'Varchar',
                'Callsign' => 'Varchar(20)',
                'KSAROperational' => "Enum('No, Yes')",
                'Sector' => "Enum('Sector2, Sector3, Sector4, Sector5, Sector6, No Sector')",
                'RecieveEmail' => 'Boolean',
                'JacketSize' => "Enum('Size, XS, S, M, L, XL, XXL, XXXL', 'Size')",
                'ShirtSize' => "Enum('Size, XS, S, M, L, XL, XXL, XXXL' , 'Size')",
                'PoliceVetted' => 'Boolean',
                'Lat' =>'Varchar',
                'Lon' =>'Varchar'
             ),
             'has_one' => array (
                'Photo' => 'Image'
             ),
             'has_many' => array (
                'Course' => 'Course',
                'SignedOut' => 'SignedOut',
                'StageAchieved' => 'StageAchieved'
             ),
             'many_many' => array (
                'Roles' => 'Role'
                ),
             
             'summary_fields' => array(
                'Sector' => 'Sector',
          'DefaultNum' => 'Number',
                'Postcode' => 'Postcode',
                'Town' => 'Town',
                'RecieveEmail' => 'Recieve Email',
                )
             
          );
       }
    public function updateCMSFields( FieldSet &$fields )
    {

       
           $fields->addFieldToTab("Root.Main", $dateField = new DateField("DOB","Date of Birth"));
          $dateField->setConfig('showcalendar', true);
       
           $fields->addFieldToTab( "Root.KSAR", new OptionSetField('Sector','Choose a Sector', singleton('Member')->dbObject('Sector')->enumValues()));
       $fields->addFieldToTab( "Root.KSAR", new DropDownField( "KSAROperational", "KSAR Operational", singleton('Member')->dbObject('KSAROperational')->enumValues()));
       $fields->addFieldToTab( "Root.Main", $upload = new ImageUploadField('Photo', 'Photo'));
          $upload->uploadFolder = 'assets/Uploads/Images/TeamMembers';
           
          $fields->removeByName('Lat');
          $fields->removeByName('Lon');
           $fields->addFieldToTab("Root.Location", new LatLongField(array(
          new TextField('Lat','Latitude'),
          new TextField('Lon','Longitude')
    ),
    array('Postcode')
    ));
          
          
          $fields->removeByName('Roles');
          $fac = DataObject::get("Role");
          $map = $fac->map('ID','Title');
          
          
          $fields->addFieldToTab(   "Root.KSAR", new CheckboxSetField( 'Roles', 'Role', $map));
             
           $fields->removeByName("PublicFieldsRaw");
          $fields->removeByName("DateFormat");
          $fields->removeByName("TimeFormat");
       $fields->removeByName("Locale");

          if(!Member::currentUser()->isAdmin()){
             $fields->removeFieldFromTab("Root", "Groups");
             $fields->removeFieldFromTab("Root", "Permissions");
          }

    }

       function MyCourses() {
          $ID = $this->owner->ID;
          return DataObject::get( "Course", "MemberID = '$ID'" );
             
    }
       
       function MyCallouts() {
          $ID = $this->owner->ID;
          return DataObject::get( "SearchTeam", "MemberID = '$ID'" );
       
       }
       function MyKit() {
          $ID = $this->owner->ID;
          return DataObject::get( "SignedOut", "MemberID = '$ID'" );
       
       }
       
    }

    regards

    Mick

  • cumquat
    Avatar
    Community Member
    189 Posts

    Re: How to implement on a dataobjectdecorator?[solved sort of] Link to this post

    Ok found a log file on the server, no mean feat as there was no real access and below is an entry.

    [Thu Apr 05 13:19:44 2012] [error] [client 82.111.128.201] PHP Fatal error: Class MemberTeamExtension contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (Mappable::getLatitude, Mappable::getLongitude, Mappable::getMapPin, ...) in /home/sites/myriadtestsite.co.uk/public_html/subs/ksar/sar/code/MemberTeamExtension.php on line 135

    Ok this has identified some missing functions have added them and now it doesn't error, doesn't work but hey doesn't error.

    Surprised the dev mode didn't spit this out?

    cheers

    for your time

    Mick

    477 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.