SilverStripe\Admin\ModelAdmin
Generates a three-pane UI for editing model classes, tabular results and edit forms.
Relies on data such as and to scaffold interfaces "out of the box", while at the same time providing
flexibility to customize the default output.
Synopsis
class ModelAdmin
extends LeftAndMain
{
- // Inherited constants from LeftAndMain
- const SCHEMA_HEADER = 'X-Formschema-Request';
- // members
- private static string $url_rule = '/$ModelClass/$Action';
- private static array|string $managed_models = NULL;
- private static integer $menu_priority = 0.5;
- private static string $menu_icon_class = 'font-icon-database';
- private static array $allowed_actions = ;
- private static array $url_handlers = ;
- protected $modelClass;
- protected $modelTab;
- public boolean $showImportForm = true;
- public boolean $showSearchForm = true;
- private static $model_importers = NULL;
- private static integer $page_length = 30;
- // Inherited members from LeftAndMain
- protected FormSchema $schema;
- protected $pageID;
- protected PjaxResponseNegotiator $responseNegotiator;
- protected VersionProvider $versionProvider;
- protected LeftAndMain_SearchFilter $searchFilterCache;
- // methods
- protected void init()
- public void Link()
- public Form getEditForm()
- protected GridField getGridField()
- protected GridFieldConfig getGridFieldConfig()
- public array getExportFields()
- public SearchContext getSearchContext()
- public ArrayList SearchSummary()
- public Form|bool SearchForm()
- public DataList getList()
- public string getModelClass()
- protected ArrayList getManagedModelTabs()
- protected string sanitiseClassName()
- protected string unsanitiseClassName()
- public array getManagedModels()
- public array getModelImporters()
- public Form|false ImportForm()
- public bool|HTTPResponse import()
- public ArrayList Breadcrumbs()
- // Inherited methods from LeftAndMain
- public string getCombinedClientConfig()
- public array getClientConfig()
- public FormSchema getFormSchema()
- public $this setFormSchema()
- public HTTPResponse schema()
- public HTTPResponse jsonError()
- public HTTPResponse methodSchema()
- protected bool getSchemaRequested()
- protected HTTPResponse getSchemaResponse()
- public bool canView()
- public static array|string|bool getRequiredPermissions()
- protected void init()
- public void handleRequest()
- public HTTPResponse|string redirect()
- public HTTPResponse index()
- public bool ShowSwitchView()
- public string Link()
- public static void menu_title_for_class()
- public static string menu_title()
- public static string menu_icon_for_class()
- public static string menu_icon_class_for_class()
- public HTTPResponse show()
- public PjaxResponseNegotiator getResponseNegotiator()
- public SS_List MainMenu()
- public void Menu()
- public ArrayData MenuCurrentItem()
- public string|array getTemplatesWithSuffix()
- public void Content()
- public DBHTMLText PreviewPanel()
- public DataObject getRecord()
- public ArrayList Breadcrumbs()
- protected LeftAndMain_SearchFilter getSearchFilter()
- public HTTPResponse save()
- public DataObject getNewItem()
- public void delete()
- public Form EditForm()
- public Form getEditForm()
- public Form EmptyForm()
- public ModalController Modals()
- public string Tools()
- public string EditFormTools()
- public void batchactions()
- public Form BatchActionsForm()
- public void printable()
- public DBHTMLText getSilverStripeNavigator()
- public int currentPageID()
- public void setCurrentPageID()
- public DataObject currentPage()
- public bool isCurrentPage()
- protected string sessionNamespace()
- public string|bool LinkPreview()
- public string CMSVersion()
- public string CMSVersionNumber()
- public array SwitchView()
- public SiteConfig SiteConfig()
- public ArrayList getHelpLinks()
- public string ApplicationLink()
- public string getApplicationName()
- public string Title()
- public string SectionTitle()
- public string LogoutURL()
- public string BaseCSSClasses()
- public string Locale()
- public void providePermissions()
- public $this setVersionProvider()
- public VersionProvider getVersionProvider()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
608+ | Figure out ajax submission of files via jQuery.form plugin |
964 | Necessary for TableListField URLs to work properly |
1117+ | Wrap in CMSMenu instance accessor |
Constants
Name | Value |
---|---|
SCHEMA_HEADER | 'X-Formschema-Request' |
Members
private
- $allowed_actions
- $managed_models
—
SilverStripe\Admin\array|string
List of all managed {@link DataObject}s in this interface. - $model_importers
—
array
List of all {@link DataObject}s which can be imported through a subclass of {@link BulkLoader} (mostly CSV data). - $page_length — int
- $url_handlers
- $url_rule
protected
- $modelClass — string
- $modelTab — string
- $pageID
—
null
Current pageID for this request - $responseNegotiator — SilverStripe\Control\PjaxResponseNegotiator
- $schema
—
SilverStripe\Forms\Schema\FormSchema
Current form schema helper - $searchFilterCache
—
SilverStripe\Admin\LeftAndMain_SearchFilter
Cached search filter instance for current search - $versionProvider — SilverStripe\Core\Manifest\VersionProvider
public
-
$showImportForm
Change this variable if you don't want the Import from CSV form to appear. -
$showSearchForm
Change this variable if you don't want the gridfield search to appear.
Methods
protected
- getGridField() — Generate the GridField field that will be used for this ModelAdmin.
- getGridFieldConfig() — Generate the GridField Configuration that will use for the ModelAdmin Gridfield.
- getManagedModelTabs()
- init() — Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins.
- sanitiseClassName() — Sanitise a model class' name for inclusion in a link
- unsanitiseClassName() — Unsanitise a model class' name from a URL param
public
- Breadcrumbs()
- ImportForm() — Generate a CSV import form for a single {@link DataObject} subclass.
- Link() — Overrides {@link \SilverStripe\Admin\LeftAndMain} to ensure the active model class (the DataObject we are currently viewing) is included in the URL.
- SearchForm() — Returns the search form
- SearchSummary() — Gets a list of fields that have been searched
- getEditForm() — Produces an edit form that includes a default {@link \SilverStripe\Forms\GridField\GridField} for the currently active {@link \SilverStripe\ORM\DataObject}. The GridField will show data from the currently active `modelClass` only (see {@link self::init()}).
- getExportFields() — Define which fields are used in the {@link getEditForm} GridField export.
- getList() — You can override how ModelAdmin returns DataObjects by either overloading this method, or defining an extension to ModelAdmin that implements the `updateList` method (and takes a {@link \SilverStripe\ORM\DataList} as the first argument).
- getManagedModels()
- getModelClass() — The model managed by this instance.
- getModelImporters() — Returns all importers defined in {@link self::$model_importers}.
- getSearchContext()
- import() — Imports the submitted CSV file based on specifications given in {@link self::model_importers}.
Inherited from SilverStripe\Admin\LeftAndMain
protected
- getSchemaRequested() — Check if the current request has a X-Formschema-Request header set.
- getSchemaResponse() — Generate schema for the given form based on the X-Formschema-Request header value
- getSearchFilter() — Gets the current search filter for this request, if available
- init()
- sessionNamespace()
public
- ApplicationLink()
- BaseCSSClasses() — Same as {@link ViewableData->CSSClasses()}, but with a changed name to avoid problems when using {@link ViewableData->customise()} (which always returns "ArrayData" from the $original object).
- BatchActionsForm()
- Breadcrumbs()
- CMSVersion() — Return the version number of this application, ie. 'CMS: 4.2.1'
- CMSVersionNumber() — Return the version number of the CMS in the 'major.minor' format, e.g. '4.2' Will handle 4.10.x-dev by removing .x-dev
- Content()
- EditForm() — Retrieves an edit form, either for display, or to process submitted data.
- EditFormTools() — Renders a panel containing tools which apply to the currently displayed edit form.
- EmptyForm() — Returns a placeholder form, used by {@link getEditForm()} if no record is selected.
- Link() — You should implement a Link() function in your subclass of LeftAndMain, to point to the URL of that particular controller.
- LinkPreview() — URL to a previewable record which is shown through this controller.
- Locale()
- LogoutURL() — Generate a logout url with BackURL to the CMS
- MainMenu() — Returns the main menu of the CMS. This is also used by init() to work out which sections the user has access to.
- Menu()
- MenuCurrentItem()
- Modals() — Handler for all global modals
- PreviewPanel() — Render $PreviewPanel content
- SectionTitle() — Return the title of the current section. Either this is pulled from the current panel's menu_title or from the first active menu
- ShowSwitchView() — If this is set to true, the "switchView" context in the template is shown, with links to the staging and publish site.
- SiteConfig()
- SwitchView()
- Title()
- Tools() — Renders a panel containing tools which apply to all displayed "content" (mostly through {@link EditForm()}), for example a tree navigation or a filter panel.
- batchactions() — Batch Actions Handler
- canView()
- currentPage() — Uses {@link getRecord()} and {@link currentPageID()} to get the currently selected record.
- currentPageID() — Identifier for the currently shown record, in most cases a database ID. Inspects the following sources (in this order): - GET/POST parameter named 'ID' - URL parameter named 'ID' - Session value namespaced by classname, e.g. "CMSMain.currentPage"
- delete()
- getApplicationName() — Get the application name.
- getClientConfig() — Returns configuration required by the client app.
- getCombinedClientConfig() — Gets the combined configuration of all LeftAndMain subclasses required by the client app.
- getEditForm() — Calls {@link SiteTree->getCMSFields()} by default to determine the form fields to display.
- getFormSchema() — Get form schema helper
- getHelpLinks() — Returns help_links in a format readable by a template
- getNewItem() — Create new item.
- getRecord() — Get dataobject from the current ID
- getRequiredPermissions() — Get list of required permissions
- getResponseNegotiator() — Caution: Volatile API.
- getTemplatesWithSuffix() — Return appropriate template(s) for this class, with the given suffix using {@link SSViewer::get_templates_by_class()}
- getVersionProvider() — Get the SilverStripe version provider
- handleRequest()
- index()
- isCurrentPage() — Compares a given record to the currently selected one (if any).
- jsonError() — Return an error HTTPResponse encoded as json
- methodSchema()
- printable()
- providePermissions()
- redirect() — Overloaded redirection logic to trigger a fake redirect on ajax requests.
- save() — Save handler
- schema() — Gets a JSON schema representing the current edit form.
- setCurrentPageID() — Forces the current page to be set in session, which can be retrieved later through {@link currentPageID()}.
- setFormSchema() — Set form schema helper for this controller
- setVersionProvider() — Set the SilverStripe version provider to use
- show()