silverstripe-framework/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extending_An_Existing_ModelAdmin.md

35 lines
873 B
Markdown
Raw Normal View History

---
title: Extending an existing ModelAdmin
summary: ModelAdmin interfaces that come with the core can be customised easily
---
2014-11-07 20:43:57 +01:00
## Extending existing ModelAdmin
Sometimes you'll work with ModelAdmins from other modules. To customise these interfaces, you can always subclass. But there's
also another tool at your disposal: The [Extension](api:SilverStripe\Core\Extension) API.
2014-11-07 20:43:57 +01:00
```php
use SilverStripe\Core\Extension;
2017-08-07 05:11:17 +02:00
class MyAdminExtension extends Extension
{
// ...
public function updateEditForm(&$form)
2017-08-07 05:11:17 +02:00
{
$form->Fields()->push(/* ... */)
2017-08-07 05:11:17 +02:00
}
}
```
2014-11-07 20:43:57 +01:00
Now enable this extension through your `[config.yml](/topics/configuration)` file.
```yml
MyAdmin:
extensions:
- MyAdminExtension
```
2014-11-07 20:43:57 +01:00
The following extension points are available: `updateEditForm()`, `updateSearchContext()`,
`updateSearchForm()`, `updateList()`, `updateImportForm`.