class GridFieldAddClassesButton implements GridField_HTMLProvider, GridField_ActionProvider (View source)

A button which allows objects to be created with a specified classname(s)

Methods

__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.

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.

array
getActions(GridField $gridField)

Return a list of the actions handled by this action provider.

handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Handle an action on the given {@link GridField}.

null
handleAdd(GridField $grid)

Handles adding a new instance of a selected class.

Details

__construct(array $classes, string $targetFragment = 'buttons-before-left')

Parameters

array $classes

Class or list of classes to create. If you enter more than one class, each click of the "add" button will create one of each

string $targetFragment

The fragment to render the button into

$this setButtonName(string $name)

Change the button name

Parameters

string $name

Return Value

$this

string getButtonName()

Get the button name

Return Value

string

string getFragment()

Gets the fragment name this button is rendered into.

Return Value

string

GridFieldAddNewInlineButton setFragment(string $fragment)

Sets the fragment name this button is rendered into.

Parameters

string $fragment

Return Value

GridFieldAddNewInlineButton

$this

string getButtonClass()

Get extra button class

Return Value

string

$this setButtonClass(string $buttonClass)

Sets extra CSS classes for this button

Parameters

string $buttonClass

Return Value

$this

array getClasses()

Get the classes of the objects to create

Return Value

array

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

Parameters

DataGrid $grid

Return Value

array

setClasses(array $classes)

Specify the classes to create

Parameters

array $classes

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 {@link GridField} is rendered.

Parameters

$grid

Return Value

array

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 {@link handleAction}.

There is no namespacing on these actions, so you need to ensure that they don't conflict with other components.

Parameters

GridField $gridField

Return Value

array

with action identifier strings.

handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Handle an action on the given {@link GridField}.

Calls ALL components for every action handled, so the component needs to ensure it only accepts actions it is actually supposed to handle.

Parameters

GridField $gridField
string $actionName

Action identifier, see {@link getActions()}.

array $arguments

Arguments relevant for this

array $data

All form data

null handleAdd(GridField $grid)

Handles adding a new instance of a selected class.

Parameters

GridField $grid

Return Value

null