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

Example usage of updateCMSFields


Go to End


5 Posts   3292 Views

Avatar
Jatinder

Community Member, 23 Posts

9 July 2010 at 10:57pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

10 July 2010 at 11:02am

Avatar
Jatinder

Community Member, 23 Posts

10 July 2010 at 3:56pm

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

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

Avatar
Willr

Forum Moderator, 5523 Posts

10 July 2010 at 4:17pm

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

Avatar
congii

Community Member, 6 Posts

18 January 2013 at 8:53pm


Hi, How do you use that in SS3?

Thanks!