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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

HasManyDataObjectManager breaks site

Go to End

15 Posts   1670 Views


22 July 2011 at 6:38am Community Member, 60 Posts

Hi. Was hopeing for a bit of help. Can't understand this one.

on page Speakers.php is have the code:

class Speakers extends DataObject {

   static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Position' => 'Text',
'Company' => 'Text',

public static $has_one = array(
      'Speaker' => 'SpeakersPage',
      'SpeakerImage' => 'Image',      

function getCMSFields_forPopup() {
$fields = new FieldSet();

$fields->push( new TextField( 'FirstName', 'First Name' ) );
$fields->push( new TextField( 'LastName' ) );
$fields->push( new TextField( 'Position' ) );
$fields->push( new TextField( 'Company' ) );
$fields->push( new ImageField('SpeakerImage') );

return $fields;


and on SpeakersPage.php

class SpeakersPage extends SiteTree {

   public static $db = array(
   'RightContent' => 'HTMLText',

   public static $has_one = array(

   public static $has_many = array(
      'MySpeakers' => 'Speakers',
    function getCMSFields() {
$fields = parent::getCMSFields();

$tablefield = new HasManyDataObjectManager(
'FirstName' => 'First Name',
'LastName' => 'Family Name',
'Position' => 'Position',
'Company' => 'Company',
'SpeakerImage' => 'Speaker Image',

$fields->addFieldToTab( 'Root.Content.Speakers', $tablefield );

This doesn't work? If I use the class 'DataObjectManager' it is fine. Of course, I would like to be able to use the HasManyDataObjectManager as each Speaker page will display different speakers. Can you point me as to where I'm going wrong here?



22 July 2011 at 7:10am 4085 Posts

What does "doesn't work" mean?


22 July 2011 at 7:14am Community Member, 60 Posts

Sorry for being vague. I get a white blank page when visiting the webpage. With just the titles of pages on the site.


22 July 2011 at 7:18am Community Member, 60 Posts

In dev mode I get the following error when visiting the CMS:

[User Error] Couldn't run query: SELECT "Speakers"."ClassName", "Speakers"."Created", "Speakers"."LastEdited", "Speakers"."FirstName", "Speakers"."LastName", "Speakers"."Position", "Speakers"."Company", "Speakers"."SortOrder", "Speakers"."SpeakerID", "Speakers"."SpeakerImageID", "Speakers"."ID", CASE WHEN "Speakers"."ClassName" IS NOT NULL THEN "Speakers"."ClassName" ELSE 'Speakers' END AS "RecordClassName", SpeakerImage FROM "Speakers" ORDER BY "SortOrder" ASC LIMIT 0, 10 Unknown column 'SpeakerImage' in 'field list'
GET /event/admin/

Line 525 in /var/www/vhosts/xxx/httpdocs/event/sapphire/core/model/MySQLDatabase.php


22 July 2011 at 8:39am Community Member, 60 Posts

At a loss of why the HasManyDataObjectManager is telling me there is an unknown column when it works with DataObjectManager and HasManyComplexTableField?


22 July 2011 at 8:45pm Community Member, 60 Posts

Can someone please help me on this? I'm stressed out my box trying to get it to work. :-(


25 July 2011 at 9:42pm Community Member, 60 Posts

I'm still struggling with this. Have no idea. At my whits end. If someone could maybe provide some pointers I would appreciate it! Am I missing something stupid?


26 July 2011 at 1:05am 4085 Posts

Well you could always just remove SpeakerImage from your field list if you really want to get it fixed fast. It's unusual to put an image right in your field list like that.. most of the time you want to put in some sort of thumbnail function or something, so it can be sized appropriately for the table.

public function getSpeakerThumbnail() {
if($this->SpeakerImage()) {
return $this->SpeakerImage()->CroppedImage(50,50);
return false;

and in your fields list:

'SpeakerThumbnail' => 'Speaker Image'

Also, I'm wondering if HasManyDOM is really what you want? It's very rarely used. Most of the time you want a DOM or a ManyManyDOM. There aren't too many models that I have seen where HasManyDOM is appropriate.

SilverStripe tips, tutorials, screencasts and more:

Go to Top