Jump to:

22999 Posts in 11854 Topics by 2828 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, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1340 Views
  • lise
    Avatar
    Community Member
    47 Posts

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

    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!

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up) Link to this post

    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'))

  • lise
    Avatar
    Community Member
    47 Posts

    Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up) Link to this post

    It worked like a charm! Thanks a lot!

  • wildflower1975
    Avatar
    Community Member
    59 Posts

    Re: Fields of ComplexTableField : Only ID shows in table (but all in pop-up) Link to this post

    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

    1340 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.