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.


Discuss SilverStripe Widgets.

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

Using HasManyComplexTableField in a Widget


3 Posts   1065 Views


13 April 2011 at 4:22am (Last edited: 13 April 2011 4:29am), Community Member, 9 Posts

Is it possible to use a HasManyComplexTableField in a Widget?

I'm trying to piece together a quick widget which will allow people to create and manage a list of links without dealing with an editor (yes, there's a need for this in my user base...).

The Widget class I have so far is:

class ListWidget extends Widget {

public static $db = array(
'Title' => 'Varchar'

public static $has_many = array(
'ListItems' => 'ListItem'

static $title = '';
static $cmsTitle = 'List of Links';
static $description = 'Create, Manage, and Title a list of links';

function Title() {
return $this->Title;

function Items() {
$output = new DataObjectSet();

$items = $this->ListItems;
foreach( $items as $item ) {
new ArrayData(
'Text' => $item->Text,
'Link' => $item->Link

return $output;


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

$titleField = new TextField( 'Title', 'Title' );
$fields->push( $titleField );

$listItemsField = new HasManyComplexTableField( $this, 'ListItems', 'ListItem', array( 'Text' => 'Text', 'Link' => 'Link' ) );
$fields->push( $listItemsField );

return $fields;


...and the ListItem DataObject looks like this:

class ListItem extends DataObject {

public static $db = array(
'Text' => 'Varchar',
'Link' => 'Varchar'

public static $has_one = array(
'ListWidget' => 'ListWidget'


This all seems like it should work, but when I try to add the Widget to a WidgetArea I get the following error:

Fatal error: Call to a member function FormAction() on a non-object in C:<webroot>\sapphire\forms\FormField.php on line 98

Any idea as to what's going on here?


13 April 2011 at 8:35am Community Member, 9 Posts


I think I've come to the conclusion that what I'm trying to do is simply impossible in SilverStripe. I'm not certain if it's because the Widget class isn't under SiteTree or what...

SilverStripe widgets have a fairly odd implementation... they're just not what I expected them to be, I guess.


28 July 2011 at 9:42am Community Member, 121 Posts

any luck on this? I tried some other form fields all referncing dataobjects which would work fine on a page but cause the same error when on a widget. anyone else had any success with this?

Call to a member function FormAction() on a non-object

cheers Will