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.