Reputation: 6569
I'm trying to extend Member class and add a number of fields to it. At the same time I am making this DataObject behave as a page so that I can go to www.mysite.com/member/show/1 and see that user's profile. I have not yet gotten to the point of created member page. Right now I have all the fields working with the exception to ImageField. I get the following error:
PHP Fatal error: Class 'ImageField' not found in ../mysite/code/Secure/Objects/MemberDecorator.php on line 66
The code is:
<?php
class MemberDecorator extends DataExtension {
private static $db = array(
"Alias" => 'Varchar',
"About" => 'Text',
"Birthday" => 'Date',
"FavoriteGames" => 'Varchar',
"Facebook" => 'Varchar',
"Twitter" => 'Varchar',
"Instagram" => 'Varchar',
"Twitch" => 'Varchar',
"Youtube" => 'Varchar',
"SecretQuestionOne" => "Varchar",
"SecretAnswerOne" => "Varchar",
"SecretQuestionTwo" => "Varchar",
"SecretAnswerTwo" => "Varchar",
"SecretQuestionThree" => "Varchar",
"SecretAnswerThree" => "Varchar"
);
private static $has_one = array(
'Photo' => 'Image'
);
//Fields to show in the DOM table
static $summary_fields = array(
'Thumb' => 'Photo',
"Alias" => 'Alias',
"About" => 'About',
"Birthday" => 'Birthday',
"FavoriteGames" => 'FavoriteGames',
"Facebook" => 'Facebook',
"Twitter" => 'Twitter',
"Instagram" => 'Instagram',
"Twitch" => 'Twitch',
"Youtube" => 'Youtube',
"SecretQuestionOne" => "SecretQuestionOne",
"SecretAnswerOne" => "SecretAnswerOne",
"SecretQuestionTwo" => "SecretQuestionTwo",
"SecretAnswerTwo" => "SecretAnswerTwo",
"SecretQuestionThree" => "SecretQuestionThree",
"SecretAnswerThree" => "SecretAnswerThree"
);
function getCMSFields() {
$fields = parent::getCMSFields();
$this->extend('updateCMSFields', $fields);
return $fields;
}
function updateCMSFields(FieldList $fields) {
$fields->push(new TextField("Alias", "Alias"), 'Members');
$fields->push(new TextAreaField("About", "About"), 'Members');
$fields->push(new DateField("Birthday", "Birthday"), 'Members');
$fields->push(new TextField("FavoriteGames", "Favorite Games"), 'Members');
$fields->push(new TextField("Facebook", "Facebook"), 'Members');
$fields->push(new TextField("Twitter", "Twitter"), 'Members');
$fields->push(new TextField("Instagram", "Instagram"), 'Members');
$fields->push(new TextField("Twitch", "Twitch"), 'Members');
$fields->push(new TextField("Youtube", "Youtube"), 'Members');
$fields->push(new TextField("SecretQuestionOne", "Secret Question One"), 'Members');
$fields->push(new TextField("SecretAnswerOne", "Secret Answer One"), 'Members');
$fields->push(new TextField("SecretQuestionTwo", "Secret Question Two"), 'Members');
$fields->push(new TextField("SecretAnswerTwo", "Secret Answer Two"), 'Members');
$fields->push(new TextField("SecretQuestionThree", "Secret Question Three"), 'Members');
$fields->push(new TextField("SecretAnswerThree", "Secret Answer Three"), 'Members');
$fields->push(new ImageField('Photo', 'Photo', Null, Null, Null, 'Uploads/member-photos/'), 'Members');
}
function Link() {
return Director::absoluteBaseURL() . SSViewer::topLevel()->URLSegment . "/member/" . $this->ID;
}
//Generate our thumbnail for the DOM
public function getThumb()
{
if($this->PhotoID)
return $this->Photo()->CMSThumbnail();
else
return '(No Image)';
}
}
According to every example out there I found and documentation, ImageField seems to be a valid field. Last bit of detail is that I am following this guide: http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/
Upvotes: 0
Views: 263
Reputation: 1809
SilverStripe 3 uses UploadField
http://api.silverstripe.org/3.1/class-UploadField.html
Upvotes: 3