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, biapar, Willr, Ingo, swaiba, simon_w

silverstripe book - error [RESOLVED]


Go to End
Reply

9 Posts   2164 Views

Avatar
chinaski

19 November 2009 at 5:23am (Last edited: 20 November 2009 11:36am), Community Member, 26 Posts

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?

Avatar
chinaski

19 November 2009 at 9:40am Community Member, 26 Posts

Solved by calling getCMSFields_forPopup() instead of just getCMSFields() in Jobs.php...

Avatar
dalesaurus

19 November 2009 at 3:19pm Community Member, 283 Posts

I was just going through that chapter myself tonight, and oh the errata...

Avatar
chinaski

20 November 2009 at 2:46am (Last edited: 20 November 2009 11:35am), Community Member, 26 Posts

The book is welcome but I'm disappointed with the lack of a decent site to support it. The [url=http://www.wiley.com/go/silverstripe]book website[/url] referenced in the preface of the book simply sucks - there's almost nothing there for someone who has actually bought the book.

Contrast this with a book like [url=http://www.manning.com/allen/]Zend Framework in Action[/url] published by Manning. The [url=http://www.zendframeworkinaction.com/]website[/url] set up for this book has a lot of information and functioning support forum, which is awesome if you want to connect with both the author(s) of the book and its readers.

Avatar
kenlomax

20 November 2009 at 5:14am Community Member, 33 Posts

There is an errata wiki page for this book at
http://doc.silverstripe.org/doku.php?id=silverstripe-book-errata
I have made a couple of postings there
You may like to post a summary of your error there also.

There is a code download at the www.wiley.com site mentioned in the front of the book.

I did not find the error you have talked about, but maybe I didnt check enough. I am currently getting towards the end of chapter 6.

Regards
Ken

Avatar
dalesaurus

20 November 2009 at 4:27pm Community Member, 283 Posts

Hey fellows, if you register for an account on the Wiki you can edit the page with your items:
http://doc.silverstripe.org/doku.php?do=login

The comments tend to get lost in the wind.

Avatar
ttyl

21 November 2009 at 8:55am Community Member, 114 Posts

The book is alright, but it isn't great. As programming books go I'd love to see something more polished come along. I went through it once in a fairly cursory way to get a feel for what it offered, but when I try to go back as a reference is largely falls flat. SS is hurting for documentation from my experience thus far.

Avatar
chinaski

21 November 2009 at 10:13am Community Member, 26 Posts

The book is going to help me as I am fairly new to the CMS and I want to do a couple of small projects with it over the next couple of months. I've looked at some other cms books and this one isn't the worst. As I said in an earlier post, the books major failing for me is that it lacks a dedicated support site.

Documentation is great. I generally like to look at how-tos, tutorials, examples, snippets, - stuff that gets you up and running in a hurry - can't get enough of that. Silverstripe as a project is doing a decent job at this and hopefully will get better as time goes on and use of the software increases.

Go to Top