\Dewdrop\Fields\Listing\BulkActionsButton

A simple bulk action implementer that you can use when you just need a single button that triggers a callback when selected. Example usage:

$bulkActions = new BulkActions($listing, $fields);

$bulkActions->addButton(
     'my_id',
     'Button Title',
     function (array $selectedItems) {
         // Your bulk action code here
     }
);
                    
                                        
                    

Summary

Methods
Properties
Constants
__construct()
setId()
setButtonTitle()
setCallback()
shouldProcess()
process()
appendStylesheet()
appendScriptFile()
setButtonClassName()
render()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$bulkActions
$id
$buttonTitle
$buttonClassName
$callback
$stylesheets
$scriptFiles
N/A

Properties

$id

$id : string

The ID that should be used on the submit button used for this action.

Type

string

$buttonTitle

$buttonTitle : string

The title to display on the button element.

Type

string

$buttonClassName

$buttonClassName : string

Classname that gets rendered on the button element.

Type

string

$callback

$callback : callable

The callback that should be run when your action is selected. The IDs (defined by the primary key field on the Listing your BulkActions apply to) of the selected items will be passed to your callable as an array.

Your callable will not be run if no items were selected.

Type

callable

$stylesheets

$stylesheets : array

Any stylesheets that should be added to the view for this button.

Type

array

$scriptFiles

$scriptFiles : array

Any JavaScript files that should be added to the view for this button.

Type

array

Methods

__construct()

__construct(\Dewdrop\Fields\Listing\BulkActions  $bulkActions) 

Provide the BulkActions object this action is associated with.

Parameters

\Dewdrop\Fields\Listing\BulkActions $bulkActions

setId()

setId(string  $id) : $this

Set the ID that should be used for the submit input of this action.

Parameters

string $id

Returns

$this

setButtonTitle()

setButtonTitle(string  $buttonTitle) : $this

Set the title of the button.

Parameters

string $buttonTitle

Returns

$this

setCallback()

setCallback(callable  $callback) : $this

Provide a callback to run when this action is selected.

Parameters

callable $callback

Returns

$this

shouldProcess()

shouldProcess() : boolean

Button actions are processed when the submit input is available in POST.

Returns

boolean

process()

process(array  $selected) : mixed

Run the action's callback. Will only be called when there are items selected, so you don't have to be paranoid about receiving an empty array.

Parameters

array $selected

Returns

mixed

appendStylesheet()

appendStylesheet(string  $stylesheet) : $this

Append a stylesheet to include when rendering this button.

Parameters

string $stylesheet

Returns

$this

appendScriptFile()

appendScriptFile(string  $scriptFile) : $this

Append a JavaScript file to include when rendering this button.

Parameters

string $scriptFile

Returns

$this

setButtonClassName()

setButtonClassName(string|array  $className) : $this

Set the classname for the button element.

Parameters

string|array $className

Returns

$this

render()

render(\Dewdrop\View\View  $view) : string

Render the submit button for this action.

Parameters

\Dewdrop\View\View $view

Returns

string