21285 Posts in 5732 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Fields of ComplexTableField : Only ID shows in table (but all in pop-up)
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1204 Views |
-
Fields of ComplexTableField : Only ID shows in table (but all in pop-up)

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!
-
Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up)

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'))
-
Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up)

4 December 2009 at 9:57am
It worked like a charm! Thanks a lot!
-
Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up)

3 February 2010 at 1:31pm Last edited: 3 February 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
| 1204 Views | ||
|
Page:
1
|
Go to Top |



