Jump to:

23481 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Example usage of updateCMSFields

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: 2430 Views
  • Jatinder
    Avatar
    Community Member
    23 Posts

    Example usage of updateCMSFields Link to this post

    Hello,

    Can anyone can give an example on how to use updateCMSFields?

    Basically I need to add a new field to Member class. My current code:

    class Client extends DataObjectDecorator {

       function extraStatics() {
          return array(
             'db' => array(
                'Phone' => 'Varchar'
             )
          );
       }

    public function updateCMSFields(FieldSet &$fields) {
    $fields->addFieldToTab('Root.Main', new TextField("Phone"));
    }

    }

    The new field (Phone) shows up fine in add/edit popup forms. But I want to display this field in summary list also.

    Thanks,
    Jatinder Singh Thind

  • Willr
    Avatar
    Forum Moderator
    5503 Posts
  • Jatinder
    Avatar
    Community Member
    23 Posts

    Re: Example usage of updateCMSFields Link to this post

    Thanks for the reply. But how do I use updateSummaryFields?

    I haven't been able to find any example usage of this method.

  • Willr
    Avatar
    Forum Moderator
    5503 Posts

    Re: Example usage of updateCMSFields Link to this post

    If you want to see usage for any update* functions its useful to look at the parent * function. summaryFields returns an associative array of "Field" => "Name" so you simply add what you want to that array

    function updateSummaryFields(&$fields) {
    $fields['Phone'] = "Phone Number";
    }

    Also looks like you could extraStatics to overload the summary_fields list

    function extraStatics() {
    return array(
    'db' => array(
    'Phone' => 'Varchar'
    ),
    'summary_fields' => array(
    'Phone' => 'Phone Number'
    )

    );
    }

  • congii
    Avatar
    Community Member
    6 Posts

    Re: Example usage of updateCMSFields Link to this post

    Hi, How do you use that in SS3?

    Thanks!

    2430 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.