As the book doesn't seem to have its own forum (shame shame), I'm posting here about an error I'm receiving. I'm working through chapter 5 of the book, and am trying to add a job to one of the JobCategory pages via the ComplexTableField.
Clicking on the add job button in the Jobs tab on the CMS admin area yields the following fatal error:
Fatal error: Call to a member function removeByName() on a non-object in /path/to/www/sapphire/forms/ComplexTableField.php on line 521
My JobCategory.php page looks like this:
class JobCategory extends Page {
static $db = array();
static $singular_name = 'Job category';
static $plural_name = 'Job categories';
static $has_many = array(
'Jobs' => 'Job'
);
static $many_many = array(
'Subscribers' => 'Member'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$jobsTable = new ComplexTableField($this, 'Jobs', 'Job');
$fields->addFieldToTab('Root.Content.Jobs', $jobsTable);
return $fields;
}
}
class JobCategory_Controller extends Page_Controller {
}
And my Jobs.php page looks like this:
class Job extends DataObject {
static $db = array(
'Title' => 'Text',
'Description' => 'Text',
'Location' => 'Text',
'ExpiryDate' => 'Date'
);
static $singular_name = 'Job';
static $plural_name = 'Jobs';
static $has_one = array(
'JobCategory' => 'JobCategory'
);
function getCMSFields() {
$fields = new FieldSet(
new TextField('Title', 'Job Title'),
new TextareaField('Description', 'Job Description'),
new TextField('Location', 'Location'),
new DateField('ExpiryDate', 'Expiry Date')
);
return fields;
}
}
Any ideas as to why I am getting this error?