21286 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1872 Views |
-
Example usage of updateCMSFields

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 -
Re: Example usage of updateCMSFields

10 July 2010 at 11:02am
For the summary field see the updateSummaryFields() function. http://api.silverstripe.org/2.4/sapphire/model/DataObjectDecorator.html#methodupdateSummaryFields
-
Re: Example usage of updateCMSFields

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.
-
Re: Example usage of updateCMSFields

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'
)
);
} -
Re: Example usage of updateCMSFields

18 January 2013 at 8:53pm
Hi, How do you use that in SS3?
Thanks!
| 1872 Views | ||
|
Page:
1
|
Go to Top |



