Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Problem adding fields to custom module

Go to End

3 Posts   1020 Views


Community Member, 4 Posts

11 April 2009 at 6:53am

I'm creating a module to handle employee information. When I create a 'jobDescription' field in my staffPage.php, it creates a jobDescriptionID field in the database and, of course, doesn't save my text value.

The code for the staffPage.php is:

class StaffPage extends Page {
static $db = array(
static $has_one = array(
	'jobDescription' => 'Text',
	'colorPhoto' => 'File',
	'bwPhoto' => 'File'
function getCMSFields() {
	$fields = parent::getCMSFields();
	$fields->addFieldToTab("Root.Content.Main", new TextField('jobDescription', 'Job description'), 'Content');
	$fields->addFieldToTab("Root.Content.Main", new FileIFrameField('colorPhoto', 'Color photo'), 'Content');
	$fields->addFieldToTab("Root.Content.Main", new FileIFrameField('bwPhoto', 'Black & white photo'), 'Content');
	$fields->renameField("Title", "Name");
	$fields->renameField("Content", "Bio");
	return $fields;
class StaffPage_Controller extends Page_Controller {


I'm using 2.30rc3.

Thanks in advance, Rick


Forum Moderator, 5523 Posts

11 April 2009 at 4:45pm

'jobDescription' => 'Text'

This is a Text Field, not a Relationship so it should be in the $db array and not the $has_one array


Community Member, 4 Posts

11 April 2009 at 6:52pm

Thanks! I totally overlooked that.