dev-master
9999999-dev http://github.com/october-widgetsList delete behavior for OctoberCMS.
MIT
The Requires
- php >=5.4.0
by Scott Bedard
owl octobercms
Wallogit.com
2017 © Pedro Peláez
List delete behavior for OctoberCMS.
List delete behavior for OctoberCMS., (*1)
, (*2)
To install the List Delete behavior, add the following to your plugin's composer.json file., (*3)
"require": {
"owl/list-delete": "~1.0@dev"
}
Next, implement the behavior in your controllers..., (*4)
public $implement = [
'Backend.Behaviors.FormController',
'Backend.Behaviors.ListController',
'Owl.Behaviors.ListDelete.Behavior', // <-- add this line
];
Then enable checkboxes in your config_list.yaml file..., (*5)
showCheckboxes: true # <-- uncomment this line
And lastly, add a button to your _list_toolbar.htm file..., (*6)
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', false)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
If you need to perform additional delete logic, simply add the following method to your controller., (*7)
public function overrideListDelete($record)
{
$record->delete();
// do whatever else you need to do
}
To override what should happen after your records are deleted, add the following method to your controller., (*8)
public function afterListDelete()
{
Flash::success('Things were deleted!');
}
By default, the list will be refreshed after a delete has occured. If you'd like to override this behavior, add the following method to your controller., (*9)
public function overrideListRefresh()
{
// do stuff here
}
List delete behavior for OctoberCMS.
MIT
owl octobercms