Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Cancel Button module allows site administrators to enable a cancel button on entity forms.
The destination where the cancel button takes the user varies based on the context.
- If the form itself has a redirect set internally (through
FormState::setRedirect()
, often used in form submit handler code), the cancel button will direct the user to the form's redirect destination. - If there is no internal form redirect in the form's submit handler code, but there is a
destination
parameter in the URL (https://www.example.com/node/1/edit?destination=/admin/content
), the cancel button will direct the user to the path in thedestination
URL parameter. - If there is no
destination
parameter in the URL, and this is the standalone edit form page for the entity (for example,https://www.example.com/node/1/edit
), the cancel button will direct the user to one of the following pages, in this order of precedence:- If the entity has a canonical page defined (a standalone 'view' page for the entity, for example
https://www.example.com/node/1
), then the cancel button will direct the user there. - If a canonical page for the entity cannot be found, but the entity type has a 'collection' page defined (for example,
https://www.example.com/admin/structure/types
for a Content Type configuration entity), then the cancel button will direct the user to the collection page. - If there is neither a canonical page nor a collection page available for the entity, and the form is for a field configuration, then the cancel button will direct the user to page that lists the fields for the bundle on which the current field appears.
- If the entity has a canonical page defined (a standalone 'view' page for the entity, for example
- If none of the above are available, the module looks at the
Referer
in the HTTP headers to see which page the user was viewing prior to accessing the form. - If there is no HTTP Referer available (for example, if the user typed the URL to the form directly into the browser, or accessed the form from a browser bookmark), then the user is directed to default cancel destination configured per entity type/bundle at
/admin/config/content/cancel-button
.
Supporting organizations:
developed this module while working for Workday.
sponsored development of this module and contributed code.
Drupal 10 maintenance and development
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Administration Tools, Content Editing Experience
- 4,804 sites report using this module
- Created by danmuzyka on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
8.x-1.4
released 20 February 2023
Works with Drupal: ^8 || ^9 || ^10
✓ Recommended by the project’s maintainer.
Install:
Development version: 8.x-1.x-dev updated 20 Feb 2023 at 19:09 UTC