GridFieldAddClassesButton
class GridFieldAddClassesButton implements GridField_HTMLProvider, GridField_ActionProvider (View source)
A button which allows objects to be created with a specified classname(s)
Properties
protected | string | $targetFragment | Name of fragment to insert into |
|
protected | string | $buttonName | Button title |
|
protected | string | $buttonClass | Additonal CSS classes for the button |
|
protected | array | $modelClasses | Class names |
Methods
Sets the fragment name this button is rendered into.
Gets the list of classes which can be created, with checks for permissions.
Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
Handle an action on the given GridField.
Details
__construct(array $classes, string $targetFragment = 'buttons-before-left')
No description
$this
setButtonName(string $name)
Change the button name
string
getButtonName()
Get the button name
string
getFragment()
Gets the fragment name this button is rendered into.
GridFieldAddNewInlineButton
setFragment(string $fragment)
Sets the fragment name this button is rendered into.
string
getButtonClass()
Get extra button class
$this
setButtonClass(string $buttonClass)
Sets extra CSS classes for this button
array
getClasses()
Get the classes of the objects to create
array
getClassesCreate(DataGrid $grid)
Gets the list of classes which can be created, with checks for permissions.
Will fallback to the default model class for the given DataGrid
setClasses(array $classes)
Specify the classes to create
array
getHTMLFragments($grid)
Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
Here are 4 built-in fragments: 'header', 'footer', 'before', and 'after', but components may also specify fragments of their own.
To specify a new fragment, specify a new fragment by including the text "$DefineFragment(fragmentname)" in the HTML that you return.
Fragment names should only contain alphanumerics, -, and _.
If you attempt to return HTML for a fragment that doesn't exist, an exception will be thrown when the GridField is rendered.
array
getActions(GridField $gridField)
Return a list of the actions handled by this action provider.
Used to identify the action later on through the $actionName parameter in handleAction.
There is no namespacing on these actions, so you need to ensure that they don't conflict with other components.
protected string
getAction()
Get the action suburl for this component
handleAction(GridField $gridField, string $actionName, array $arguments, array $data)
Handle an action on the given GridField.
Calls ALL components for every action handled, so the component needs to ensure it only accepts actions it is actually supposed to handle.
null
handleAdd(GridField $grid)
Handles adding a new instance of a selected class.