Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Extend Member class using dataobjectdecorator ERROR

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1964 Views
  • McBainVT
    Avatar
    Community Member
    5 Posts

    Extend Member class using dataobjectdecorator ERROR Link to this post

    I have read through a bunch of the posts on this forum and all of the documentation I can find but I can't figure out how to add a few fields to the member class. I have tried using the dataobjectdecorator to do this, but I get this error when /dev/build the website. I am in dev mode currently if that matters. I am also using the most current version of silverstripe 2.3.2 and I do have dataobject_manager module successfully added/installed.

    [Notice] Undefined variable: _SESSION
    GET /samplebusiness/dev/build

    Line 120 in /home/mcshane1/public_html/samplebusiness/sapphire/core/control/Director.php

    Source

    111          @file_get_contents('php://input')
    112       );
    113       
    114       // @todo find better way to extract HTTP headers
    115       if(isset($_SERVER['HTTP_ACCEPT'])) $req->addHeader("Accept", $_SERVER['HTTP_ACCEPT']);
    116       if(isset($_SERVER['CONTENT_TYPE'])) $req->addHeader("Content-Type", $_SERVER['CONTENT_TYPE']);
    117       if(isset($_SERVER['HTTP_REFERER'])) $req->addHeader("Referer", $_SERVER['HTTP_REFERER']);
    118
    119       // Load the session into the controller
    120       $session = new Session($_SESSION);
    121       $result = Director::handleRequest($req, $session);
    122       $session->inst_save();
    123
    124       // Return code for a redirection request
    125       if(is_string($result) && substr($result,0,9) == 'redirect:') {
    126          $response = new HTTPResponse();

    Trace

    * Director::direct(/dev/build)
    Line 118 of main.php

    Line 120 shows up in red, so that must be what the error is?

    The site does function after displaying that error but whenever I try to login it just redirects me back security/login screen, even though I have entered the correct email and password. I don't have the same problem and login works perfectly when I am not attempting to use dataobjectdecorator.

    Here is the code I am using for my memberdecorator file.

    class MemberDecorator extends DataObjectDecorator {

    function augmentSQL(SQLQuery &$query) {}

       public function extraStatics() {
       
    return array(
    'db' => array(
    "Website" => "Text",
          "Username" => "Text",      
    ),
    'has_one' => array(
    "Avatar" => "Image",
    ),
    );
    }

       public function getCMSFields() {
          $this->extend('updateCMSFields', $fields);
          return $fields;
       }

       public function updateCMSFields(FieldSet &$fields) {
       $fields->push(new TextField("Username", "Username"), 'Members');
          $fields->push(new TextField("Website", "Website URL"), 'Members');
       $fields->push(new ImageField("Avatar", "Profile Image"), 'Members');
    }
    }

    Can anyone please tell me if there are any errors in the file, with all the old and outdated info I have seen in the docs it is quite possible I am using some out of date methods that no longer work with this silverstripe version. Any help would be greatly appreciated.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Extend Member class using dataobjectdecorator ERROR Link to this post

    That error is almost always due to outputting to the browser before headers are sent. Make sure you don't have any echo, var_dump, or other debugging statements kicking around. That will often trip up the page load.

  • McBainVT
    Avatar
    Community Member
    5 Posts

    Re: Extend Member class using dataobjectdecorator ERROR Link to this post

    Yea it does appear to kick out that same error, no matter what I am putting in the memberdecorator file. I looked around through all my files but there isn't any echo statements, var_dump, or anything I could see that would output to the browser before the headers are sent.

    Do you have any idea if there is any place or file that causes this error typically?

    I am succussfully using dataobjectdecorator for 'Groups', it only throws this error when I am attempting to use dataobjectdecorator for the member class, dunno if that information is useful or not.

  • McBainVT
    Avatar
    Community Member
    5 Posts

    Re: Extend Member class using dataobjectdecorator ERROR Link to this post

    Nevermind figured it out. Had a space after php close tag in memberdecorator. thank you for your help uncle cheese, I am new to silverstripe and was assuming my error was caused by me not knowing how to correctly use the dataobjectdecorator but apparently it was just that space, works fine now.

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