Fork me on GitHub
Heads up!
These docs are for Crud v3 - that only works with CakePHP 2.x. For CRUD v4 docs please go to the new documentation site
The CRUD v4 documentation has been completely rewritten, and since CRUD v3 and CRUD v4 API is ~95% identical, it may be worth a look for CRUD v3 users as well until v4 docs are backported for v3.
...toc....

Delete CrudAction

The delete CrudAction will delete a record if the request is HTTP DELETE or HTTP POST and the ID that is part of the request exist in the database.

Relevant links: PHP source code | API documentation

Events

This is a list of events emitted from the CrudAction

In addition to the subject properties listed below, there is also a long list of objects that are always available in all events.
Please see the events documentation for a full list of subject properties and how to use the event system correctly.

Event Subject modifiers Description
Crud.startup None Called after the Controller::beforeFilter() and before the Crud action
Crud.initialize None Triggered when a CrudAction is going to handle a CakePHP.
Crud.beforeFind findMethod
query
findMethod maps to the 1st argument of Model::find(). The default value is all.
query maps to the 2nd argument of Model::find(). e.g. fields, conditions, contain etc.
Crud.recordNotFound id If beforeFind could not find a record this event is emitted
Crud.beforeDelete id id The ID of the record that will be deleted.
Executed before Model::delete() is called.
Stop the delete by redirecting away from the action or calling $event->stopPropagation().
Crud.afterDelete id
success
id The ID of the record that should be deleted.
success Whether the Model::delete() succeeded or not.
Executed after Model::delete() has called
Crud.beforeRedirect url
status
exit
url A string or Router::url() compatible array
status A redirect status code
exit Should exit(); be called after redirect?
Invoked right before a call to Controller::redirect() is made.
This is also before the controllers own beforeRedirect callback

Configuration

This is the configuration options for the Crud action class

Please see the configuration documentation on how to change these settings

Key Default value Description
enabled true If this action is enabled or not.
findMethod all (index)
first (edit, view)
count (delete)
The 1st parameter to Model::find or Model::paginate().
secureDelete true If true, an exception will be thrown if the request isn't of type HTTP DELETE
If false both HTTP DELETE and HTTP POST is valid request methods.

Methods

This is a list of the most relevant public methods in the Crud action class.

For a full list please see the full API documentation

Method Description
findMethod($method = NULL) Get or set the findMethod configuration setting.
If $method is NULL the current findMethod will be returned.
If $method is a string, the setting will be changed.



comments powered by Disqus