diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index cea94aebc1..ec2b930aaa 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -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 ============ @@ -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 --- @@ -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 ----- diff --git a/en/tutorials-and-examples/cms/articles-controller.rst b/en/tutorials-and-examples/cms/articles-controller.rst index 9d32e517eb..975e9c5b68 100644 --- a/en/tutorials-and-examples/cms/articles-controller.rst +++ b/en/tutorials-and-examples/cms/articles-controller.rst @@ -530,7 +530,7 @@ that allow users to delete articles: Html->link('Edit', ['action' => 'edit', $article->slug]) ?> - Form->postLink( + Form->deleteLink( 'Delete', ['action' => 'delete', $article->slug], ['confirm' => 'Are you sure?']) @@ -541,8 +541,9 @@ that allow users to delete articles: -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:: diff --git a/en/views/helpers/form.rst b/en/views/helpers/form.rst index 3cc3980c8a..f74d06c855 100644 --- a/en/views/helpers/form.rst +++ b/en/views/helpers/form.rst @@ -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 = []) * ``$title`` - Mandatory string providing the text to be wrapped in ```` tags. @@ -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 ```` + 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 + Form->deleteLink( + 'Delete', + ['action' => 'delete', $article->id], + ['confirm' => 'Are you sure?']) + ?> + Customizing the Templates FormHelper Uses =========================================