Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] How to delete item from DataObject via front end

Go to End

3 Posts   975 Views

Optic Blaze

Community Member, 190 Posts

2 October 2013 at 10:44am

Hi there,

I am trying my hand at some front end forms and i have created a dataobject called Customers.
I can list my customers with the following code in the front end:

// Display list of customers
function ShowCustomers() {
return Customer::get();

But how do i delete a customer? At the moment i have this:

// Delete customer
function DeleteCustomer() {
$SQL_id = (int) $this->ID;
echo $SQL_id;
$page = DataObject::get_by_id('Customer', $SQL_id);



Forum Moderator, 5523 Posts

4 October 2013 at 8:01pm


To delete an object simply called delete. $obj->delete()

Optic Blaze

Community Member, 190 Posts

4 October 2013 at 9:24pm

Thanks Willr,

I did the following and it worked for deleting a record in the customer.php dataobject
//Set permission to allow deletion function below
public static $allowed_actions = array ('delete');

//Delete customer when the following is typed in URL: customer/delete/10 (the record to delete)
public function delete ($request) {
$param = $request->allParams();
$delparam = $param["ID"];