From b9e375c0a98cfb02feb011e7e49ed56dc1fecc45 Mon Sep 17 00:00:00 2001 From: Murilo Lobato Date: Fri, 7 Apr 2017 17:59:01 -0300 Subject: [PATCH 1/5] Added caution block under delete_empty to warn the developer when he try to activate delete_empty for collections of compound forms. --- reference/forms/types/collection.rst | 7 +++++++ reference/forms/types/form.rst | 2 ++ 2 files changed, 9 insertions(+) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 1bfe653e4e8..a618bce9bb7 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -268,6 +268,13 @@ delete_empty **type**: ``Boolean`` **default**: ``false`` +.. caution:: + + Delete empty will only remove items when the normalized value is null. + If your `type`_ is a compound form type, you need to have the :ref:`required ` + option set to ``false`` inside `options`_, See :ref:`empty_data `. + + If you want to explicitly remove entirely empty collection entries from your form you have to set this option to true. However, existing collection entries will only be deleted if you have the allow_delete_ option enabled. Otherwise diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index b7d0e8e96f5..6c57283941e 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -80,6 +80,8 @@ option on the form. .. include:: /reference/forms/types/options/data_class.rst.inc +.. _reference-form-option-empty-data: + .. include:: /reference/forms/types/options/empty_data.rst.inc :end-before: DEFAULT_PLACEHOLDER From ca045553edfd70e0321ca9f5068c32157b5112e2 Mon Sep 17 00:00:00 2001 From: Murilo Lobato Date: Sat, 8 Apr 2017 00:37:10 -0300 Subject: [PATCH 2/5] Improved format of message and added missing information. --- reference/forms/types/collection.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index a618bce9bb7..d60993677c6 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -268,18 +268,20 @@ delete_empty **type**: ``Boolean`` **default**: ``false`` -.. caution:: - - Delete empty will only remove items when the normalized value is null. - If your `type`_ is a compound form type, you need to have the :ref:`required ` - option set to ``false`` inside `options`_, See :ref:`empty_data `. - - If you want to explicitly remove entirely empty collection entries from your form you have to set this option to true. However, existing collection entries will only be deleted if you have the allow_delete_ option enabled. Otherwise the empty values will be kept. +.. caution:: + + The ``delete_empty`` option will only remove items when the normalized + value is null. If your `type`_ is a compound form type, you need to have + the ``required`` option set to false or ``empty_data`` option explicitly + set to null, both these options can be set inside `options`_. To + understand why this is necessary, see form + :ref:`empty_data `. + options ~~~~~~~ From de25ede4310c7d8d40e857df1df9a80db55e207d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 8 Apr 2017 10:00:25 +0200 Subject: [PATCH 3/5] Minor reword --- reference/forms/types/collection.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index d60993677c6..35a55912d09 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -275,12 +275,12 @@ the empty values will be kept. .. caution:: - The ``delete_empty`` option will only remove items when the normalized - value is null. If your `type`_ is a compound form type, you need to have - the ``required`` option set to false or ``empty_data`` option explicitly - set to null, both these options can be set inside `options`_. To - understand why this is necessary, see form - :ref:`empty_data `. + The ``delete_empty`` option only removes items when the normalized value is + ``null``. If your `type`_ is a compound form type, you must either set the + ``required`` option to ``false`` or set the ``empty_data`` option to ``null``. + Both of these options can be set inside `options`_. See + :ref:`form's empty_data option ` to learn + why this is necessary. options ~~~~~~~ From 52c0a94eb4d717a4490e0c1becbf614ed1a54dbc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 8 Apr 2017 11:11:20 +0200 Subject: [PATCH 4/5] Minor fix --- reference/forms/types/collection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 35a55912d09..fd7033a1753 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -275,7 +275,7 @@ the empty values will be kept. .. caution:: - The ``delete_empty`` option only removes items when the normalized value is + The ``delete_empty`` option only removes items when the normalized value is ``null``. If your `type`_ is a compound form type, you must either set the ``required`` option to ``false`` or set the ``empty_data`` option to ``null``. Both of these options can be set inside `options`_. See From ce30e472e3ea3d2d7c4cc74dc08ec835300f7461 Mon Sep 17 00:00:00 2001 From: Murilo Date: Sat, 29 Apr 2017 00:21:14 -0300 Subject: [PATCH 5/5] Applied reviewer suggestion --- reference/forms/types/collection.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index fd7033a1753..8153e6c1eec 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -276,9 +276,9 @@ the empty values will be kept. .. caution:: The ``delete_empty`` option only removes items when the normalized value is - ``null``. If your `type`_ is a compound form type, you must either set the - ``required`` option to ``false`` or set the ``empty_data`` option to ``null``. - Both of these options can be set inside `options`_. See + ``null``. If the nested `type`_ is a compound form type, you must either set + the ``required`` option to ``false`` or set the ``empty_data`` option to + ``null``. Both of these options can be set inside `options`_. See :ref:`form's empty_data option ` to learn why this is necessary.