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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

Fields of ComplexTableField : Only ID shows in table (but all in pop-up)


Go to End


4 Posts   1818 Views

Avatar
lise

Community Member, 47 Posts

4 December 2009 at 9:09am

I am following the example (Chapter 5) to create a ComplexTableField and it works OK excepted that the table I get in the CMS
tab displays only one column :"ID" .
However , the pop-up windows correctly displays *all* the fields of the DataObject.
How can I configure which fields appear in the tab-table (i.e the table with the standard icons) ?

Here is the code :

function getCMSFields() {
$fields = parent::getCMSFields();
$postsTable = new ComplexTableField($this, 'AGPost', 'AGPost');
$fields->addFieldToTab('Root.Content.AGPost', $postsTable);
return $fields;
}

Any help would be highly appreciated. I looked at the documentation on ComplexTableField but could not find the answer.
(http://doc.silverstripe.org/doku.php?id=complextablefield)

Thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

4 December 2009 at 9:40am

This is probably because you haven't passed a field list to the ComplexTableField. As per the examples on that documentation page you need to specify a 4th argument which is the fields to display. The popup works as the form scaffolder does all the heavy lifting.

Change

 new ComplexTableField($this, 'AGPost', 'AGPost')

To something like

 new ComplexTableField($this, 'AGPost', 'AGPost', array('Title'=>'Title', 'OtherField'=> 'Some Field'))

Avatar
lise

Community Member, 47 Posts

4 December 2009 at 9:57am

It worked like a charm! Thanks a lot!

Avatar
wildflower1975

Community Member, 63 Posts

3 February 2010 at 1:31pm

Edited: 03/02/2010 1:44pm

Hi Will

I've managed to get my custom object displaying Ok but would like to add more fields to the Summary table namely the CaseManager which is a Member as per below.

class CreditApplicationSubmission extends DataObject {
static $has_one = array(
'CaseManager' => 'Member');
}

$applicationsTable = new ComplexTableField($this, 'CreditApplications', 'CreditApplicationSubmission', array('Goods' => 'Goods', 'AmountSought' => 'AmountSought', 'CaseManager' => 'CaseManager' ));

However when I do this I get a no forTemplate on Object Member error, but the CaseManger field shows correctly as a select box with current members in the popup edit box.

I tried copying the forTemplate method from cms/code/MemberTableField.php into sapphire/security/Member.php without success.

thanks

I found an answer here for when using ModelAdmin instead :) (but I'd still like to know about ComplexTableField)

http://doc.silverstripe.org/doku.php?id=dataobject&s=summaryfields#summary_fields