Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deleteLink(). #7982

Open
wants to merge 2 commits into
base: 5.next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions en/appendices/5-2-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ Behavior Changes
being filterable from logging.
- ``NumericPaginator::paginate()`` now uses the ``finder`` option even when a ``SelectQuery`` instance is passed to it.

New Features
============

- ``Cake\Database\Type\JsonType::setDecodingOptions()`` was added. This method
lets you define the value for the ``$flags`` argument of ``json_decode()``.
- ``CounterCacheBehavior::updateCounterCache()`` was added. This method allows
you to update the counter cache values for all records of the configured
associations. ``CounterCacheCommand`` was also added to do the same through the
console.

Deprecations
============
Expand Down Expand Up @@ -75,11 +66,15 @@ Console
Database
--------

- ``JsonType::setDecodingOptions()`` was added. This method lets you define the
bitmask options used by ``json_encode()`` calls.
- The ``nativeuuid`` type was added. This type enables ``uuid`` columns to be
used in Mysql connections with MariaDB. In all other drivers, ``nativeuuid``
is an alias for ``uuid``.
- ``Cake\Database\Type\JsonType::setDecodingOptions()`` was added. This method
lets you define the value for the ``$flags`` argument of ``json_decode()``.
- ``CounterCacheBehavior::updateCounterCache()`` was added. This method allows
you to update the counter cache values for all records of the configured
associations. ``CounterCacheCommand`` was also added to do the same through the
console.

ORM
---
Expand All @@ -88,6 +83,12 @@ ORM
allows you to update the counter cache values for all records of the configured
associations.

View
----

- ``FormHelper::deleteLink()`` has been added as convenience wrapper for delete links in
templates using `DELETE` method.

Error
-----

Expand Down
7 changes: 4 additions & 3 deletions en/tutorials-and-examples/cms/articles-controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ that allow users to delete articles:
</td>
<td>
<?= $this->Html->link('Edit', ['action' => 'edit', $article->slug]) ?>
<?= $this->Form->postLink(
<?= $this->Form->deleteLink(
'Delete',
['action' => 'delete', $article->slug],
['confirm' => 'Are you sure?'])
Expand All @@ -541,8 +541,9 @@ that allow users to delete articles:

</table>

Using :php:meth:`~Cake\\View\\Helper\\FormHelper::postLink()` will create a link
that uses JavaScript to do a POST request deleting our article.
Using :php:meth:`~Cake\\View\\Helper\\FormHelper::deleteLink()` will create a link
that uses JavaScript to do a DELETE request deleting our article.
Prior to CakePHP 5.2 you need to use ``postLink()`` instead.

.. note::

Expand Down
25 changes: 24 additions & 1 deletion en/views/helpers/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ inside opened forms.
Creating POST Links
-------------------

.. php:method:: postLink(string $title, mixed $url = null, array $options = [])
.. php:method:: postLink(string $title, array|string|null $url = null, array $options = [])
dereuromark marked this conversation as resolved.
Show resolved Hide resolved

* ``$title`` - Mandatory string providing the text to be wrapped in ``<a>``
tags.
Expand Down Expand Up @@ -2170,6 +2170,29 @@ use :php:meth:`\\Cake\\View\\Helper\\FormHelper::button()` or

.. _customizing-templates:

Creating DELETE Links
-------------------

.. php:method:: deleteLink(string $title, array|string|null $url = null, array $options = [])

* ``$title`` - Mandatory string providing the text to be wrapped in ``<a>``
tags.
* ``$url`` - Optional. String or array which contains the URL
of the form (Cake-relative or external URL starting with ``http://``).
* ``$options`` - An optional array including any of the
:ref:`general-control-options`, or of the specific options (see below) as well
as any valid HTML attributes.

Creates an HTML link, but accesses the URL using the method you specify
(defaults to DELETE). Requires JavaScript to be enabled in browser::

// In your template, to delete an article, for example
<?= $this->Form->deleteLink(
'Delete',
['action' => 'delete', $article->id],
['confirm' => 'Are you sure?'])
?>

Customizing the Templates FormHelper Uses
=========================================

Expand Down
Loading