Version: current

# Class ModelAdmin

Generates a three-pane UI for editing model classes, with an automatically generated search panel, tabular results and edit forms. Relies on data such as `DataObject::$db` and {@DataObject::getCMSFields()} to scaffold interfaces "out of the box", while at the same time providing flexibility to customize the default output.

Add a route (note - this doc is not currently in sync with the code, need to update)

    Director::addRules(50, array('admin/mymodel/$Class/$Action/$ID' => 'MyModelAdmin'));

  Object
  ViewableData implements IteratorAggregate
  RequestHandler
  Controller
  LeftAndMain
  ModelAdmin

### Direct known subclasses

`BookingOrderAdmin`, `CatalogAdmin`, `ProductImport1CAdmin`, `ProductImportAdmin`, `RealtyImportAdmin`, `RedirectEntry_Admin`, `RoomServiceAdmin`, `ShippingMethodAdmin`, `SubsiteAdmin`, `VAT_Admin`, `VKNotificationQueueAdmin`, `GuestbookAdmin`, `ImportCatalog1C_ProductProp_Admin`, `LoggerAdmin`, `MonumentAdmin`, `NewDocumentsAdmin`, `OrderAdmin`, `PaymentAdmin`, `PollPage`

Abstract
Package: cms\core
Uses: ``SearchContext``
Located at cms/code/ModelAdmin.php

## Methods summary

`public` | # `resultsTableClassName( )` Return $this->resultsTableClassName Return $this->resultsTableClassName
`public` | # `init( )` Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins. Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins. #### Overrides `LeftAndMain::init`
`public static` | # `set_page_length( mixed $length )` overwrite the static page_length of the admin panel, should be called in the project _config file. overwrite the static page_length of the admin panel, should be called in the project _config file.
`public static` | # `get_page_length( )` Return the static page_length of the admin, default as 30 Return the static page_length of the admin, default as 30
`public string` | # `getCollectionControllerClass( string $model )` Return the class name of the collection controller Return the class name of the collection controller #### Parameters $model string $model model name to get the controller for #### Returns `string` the collection controller class
`public string` | # `getRecordControllerClass( string $model )` Return the class name of the record controller Return the class name of the record controller #### Parameters $model string $model model name to get the controller for #### Returns `string` the record controller class
`public` | # `defineMethods( )` Add mappings for generic form constructors to automatically delegate to a scaffolded form object. Add mappings for generic form constructors to automatically delegate to a scaffolded form object. #### Overrides `ViewableData::defineMethods`
`public` | # `bindModelController( mixed $model, mixed $request = null )` Base scaffolding method for returning a generic model instance. Base scaffolding method for returning a generic model instance.
`public` | # `LangSelector( )` Returns all languages with languages already used appearing first. Called by the SSViewer when rendering the template. Returns all languages with languages already used appearing first. Called by the SSViewer when rendering the template.
`public boolean` | # `IsTranslatableEnabled( mixed $model = false )` #### Returns `boolean` boolean
`public String:` | # `SearchClassSelector( )` This method can be overloaded to specify the UI by which the search class is chosen. This method can be overloaded to specify the UI by which the search class is chosen. It can create a tab strip or a dropdown. The dropdown is useful when there are a large number of classes. By default, it will show a tabs for 1-3 classes, and a dropdown for 4 or more classes. #### Returns `String:` 'tabs' or 'dropdown'
`protected `DataObjectSet`` | # `getModelForms( )` Returns managed models' create, search, and import forms Returns managed models' create, search, and import forms #### Returns ``DataObjectSet`` of forms #### Uses ``SearchContext`` ``SearchFilter``
`public array` | # `getManagedModels( )` #### Returns `array` array
`public array` | # `getModelImporters( )` Returns all importers defined in `ModelAdmin::$model_importers`. If none are defined, we fall back to `ModelAdmin::$managed_models` with a default `CsvBulkLoader` class. In this case the column names of the first row in the CSV file are assumed to have direct mappings to properties on the object. Returns all importers defined in `ModelAdmin::$model_importers`. If none are defined, we fall back to `ModelAdmin::$managed_models` with a default `CsvBulkLoader` class. In this case the column names of the first row in the CSV file are assumed to have direct mappings to properties on the object. #### Returns `array` array

### Methods inherited from LeftAndMain

`ApplicationLink()`, `CMSTopMenu()`, `CMSVersion()`, `CanOrganiseSitetree()`, `EditForm()`, `EditorToolbar()`, `EmptyForm()`, `ForceReload()`, `Left()`, `Link()`, `LoadingImage()`, `LogoStyle()`, `MainMenu()`, `MceRoot()`, `Member_ProfileForm()`, `Right()`, `SectionTitle()`, `ShowSwitchView()`, `SwitchView()`, `addTreeNodeJS()`, `ajaxupdateparent()`, `ajaxupdatesort()`, `callPageMethod()`, `canView()`, `currentPage()`, `currentPageID()`, `deleteTreeNodeJS()`, `deleteitems()`, `getActionUpdateJS()`, `getApplicationLogoText()`, `getApplicationName()`, `getLastFormIn()`, `getRecord()`, `getSiteTreeFor()`, `getTemplatesWithSuffix()`, `getitem()`, `getsubtree()`, `isCurrentPage()`, `menu_title_for_class()`, `myprofile()`, `printable()`, `require_css()`, `require_javascript()`, `require_themed_css()`, `returnItemToUser()`, `save()`, `setApplicationName()`, `setCurrentPageID()`, `setLogo()`, `set_loading_image()`, `show()`, `versionFromVersionFile()`

### Methods inherited from Controller

`CurrentMember()`, `Now()`, `PastMember()`, `PastVisitor()`, `can()`, `curr()`, `defaultAction()`, `disableBasicAuth()`, `getAction()`, `getFormOwner()`, `getRequest()`, `getResponse()`, `getSession()`, `getURLParams()`, `getViewer()`, `handleAction()`, `handleRequest()`, `hasAction()`, `hasActionTemplate()`, `has_curr()`, `isAjax()`, `join_links()`, `popCurrent()`, `pushCurrent()`, `redirect()`, `redirectBack()`, `redirectedTo()`, `render()`, `setSession()`, `setURLParams()`

### Methods inherited from RequestHandler

`__construct()`, `allowedActions()`, `checkAccessAction()`, `httpError()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `hasField()`, `hasValue()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`, `setField()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static string` | $url_rule | #
`public static array|string` | $managed_models | # List of all managed `DataObject`s in this interface. List of all managed `DataObject`s in this interface. Simple notation with class names only:
    array('MyObjectClass','MyOtherObjectClass')
Extended notation with options (e.g. custom titles):
    array(
      'MyObjectClass' => array('title' => "Custom title")
    )
Available options: 'title': Set custom titles for the tabs or dropdown names 'collection_controller': Set a custom class to use as a collection controller for this model 'record_controller': Set a custom class to use as a record controller for this model
`public static array` | $allowed_actions | # More actions are dynamically added in `ModelAdmin::defineMethods()` below. More actions are dynamically added in `ModelAdmin::defineMethods()` below.
`public static string` | $collection_controller_class | # #### Param string $collection_controller_class Override for controller class
`public static string` | $record_controller_class | # #### Param string $collection_controller_class Override for controller class
`public static array` | $url_handlers | # Forward control to the default action handler Forward control to the default action handler
`public static array` | $model_importers | # List of all `DataObject`s which can be imported through a subclass of `BulkLoader` (mostly CSV data). By default `CsvBulkLoader` is used, assuming a standard mapping of column names to `DataObject` properties/relations. List of all `DataObject`s which can be imported through a subclass of `BulkLoader` (mostly CSV data). By default `CsvBulkLoader` is used, assuming a standard mapping of column names to `DataObject` properties/relations. e.g. "BlogEntry" => "BlogEntryCsvBulkLoader"
`public static integer` | $page_length | # Amount of results showing on a single page. Amount of results showing on a single page.
`protected string` | $resultsTableClassName | # Class name of the form field used for the results list. Overloading this in subclasses can let you customise the results table field. Class name of the form field used for the results list. Overloading this in subclasses can let you customise the results table field.

### Properties inherited from LeftAndMain

`$ForceReload`, `$application_link`, `$application_logo`, `$application_logo_style`, `$application_logo_text`, `$application_name`, `$extra_requirements`, `$loading_image`, `$menu_priority`, `$menu_title`, `$tree_class`, `$url_base`, `$url_priority`, `$url_segment`

### Properties inherited from Controller

`$action`, `$baseInitCalled`, `$basicAuthEnabled`, `$controller_stack`, `$request`, `$requestParams`, `$response`, `$session`, `$urlParams`

### Properties inherited from RequestHandler

`$brokenOnConstruct`

### Properties inherited from ViewableData

`$casting`, `$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -