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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

silverstripe book - error [RESOLVED]


Go to End


9 Posts   3873 Views

Avatar
chinaski

Community Member, 26 Posts

19 November 2009 at 5:23am

Edited: 20/11/2009 11:36am

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

Community Member, 26 Posts

19 November 2009 at 9:40am

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

Avatar
dalesaurus

Community Member, 283 Posts

19 November 2009 at 3:19pm

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

Avatar
chinaski

Community Member, 26 Posts

20 November 2009 at 2:46am

Edited: 20/11/2009 11:35am

The book is welcome but I'm disappointed with the lack of a decent site to support it. The book website 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 Zend Framework in Action published by Manning. The website 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

Community Member, 33 Posts

20 November 2009 at 5:14am

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

Community Member, 283 Posts

20 November 2009 at 4:27pm

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

Community Member, 114 Posts

21 November 2009 at 8:55am

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

Community Member, 26 Posts

21 November 2009 at 10:13am

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