class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URLHandler (View source)

A component which lets the user select from a list of classes to create a new record form.

By default the list of classes that are createable is the grid field's model class, and any subclasses. This can be customised using setClasses().

Properties

protected string $itemRequestClass

Methods

public
__construct(string $fragment = 'before')

No description

public
string
getFragment()

Gets the fragment name this button is rendered into.

public
setFragment(string $fragment)

Sets the fragment name this button is rendered into.

public
string
getTitle()

Gets the button title text.

public
setTitle(string $title)

Sets the button title text.

public
array
getClasses(GridField $grid)

Gets the classes that can be created using this button, defaulting to the model class and its subclasses.

public
setClasses(array $classes, $default = null)

Sets the classes that can be created using this button.

public
setDefaultClass(string $default)

Sets the default class that is selected automatically.

public
handleAdd(GridField $grid, SS_HTTPRequest $request)

Handles adding a new instance of a selected class.

public
array
getHTMLFragments($grid)

Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.

public
getURLHandlers($grid)

Return URLs to be handled by this grid field, in an array the same form as $url_handlers.

public
setItemRequestClass($class)

No description

protected
string
sanitiseClassName($class)

Sanitise a model class' name for inclusion in a link

protected
string
unsanitiseClassName($class)

Unsanitise a model class' name from a URL param

Details

__construct(string $fragment = 'before')

No description

Parameters

string $fragment

the fragment to render the button in

string getFragment()

Gets the fragment name this button is rendered into.

Return Value

string

GridFieldAddNewMultiClass setFragment(string $fragment)

Sets the fragment name this button is rendered into.

Parameters

string $fragment

Return Value

GridFieldAddNewMultiClass $this

string getTitle()

Gets the button title text.

Return Value

string

GridFieldAddNewMultiClass setTitle(string $title)

Sets the button title text.

Parameters

string $title

Return Value

GridFieldAddNewMultiClass $this

array getClasses(GridField $grid)

Gets the classes that can be created using this button, defaulting to the model class and its subclasses.

Parameters

GridField $grid

Return Value

array

a map of class name to title

GridFieldAddNewMultiClass setClasses(array $classes, $default = null)

Sets the classes that can be created using this button.

Parameters

array $classes

a set of class names, optionally mapped to titles

$default

Return Value

GridFieldAddNewMultiClass $this

GridFieldAddNewMultiClass setDefaultClass(string $default)

Sets the default class that is selected automatically.

Parameters

string $default

the class name to use as default

Return Value

GridFieldAddNewMultiClass $this

GridFieldAddNewMultiClassHandler handleAdd(GridField $grid, SS_HTTPRequest $request)

Handles adding a new instance of a selected class.

Parameters

GridField $grid
SS_HTTPRequest $request

Return Value

GridFieldAddNewMultiClassHandler

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.

Parameters

$grid

Return Value

array

getURLHandlers($grid)

Return URLs to be handled by this grid field, in an array the same form as $url_handlers.

Handler methods will be called on the component, rather than the GridField.

Parameters

$grid

setItemRequestClass($class)

No description

Parameters

$class

protected string sanitiseClassName($class)

Sanitise a model class' name for inclusion in a link

Parameters

$class

Return Value

string

protected string unsanitiseClassName($class)

Unsanitise a model class' name from a URL param

Parameters

$class

Return Value

string