Skip to content

Commit f375489

Browse files
committed
Better explain empty_data values
1 parent d552ea3 commit f375489

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

form/use_empty_data.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ a ``data_class`` option for your form class, it will default to a new instance
2727
of that class. That instance will be created by calling the constructor
2828
with no arguments.
2929

30-
If you want to override this default behavior, there are two ways to do this.
30+
If you want to override this default behavior, there are two ways to do this:
31+
32+
* `Option 1: Instantiate a new Class`_
33+
* `Option 2: Provide a Closure`_
34+
35+
If you didn't set the ``data_class`` option, you can pass the initial data as
36+
string or pass an array of strings (where the key matches the field name) when
37+
the form type is compound.
3138

3239
Option 1: Instantiate a new Class
3340
---------------------------------

reference/forms/types/options/empty_data.rst.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ This will still render an empty text box, but upon submission the ``John Doe``
2626
value will be set. Use the ``data`` or ``placeholder`` options to show this
2727
initial value in the rendered form.
2828
29-
If a form is compound, you can set ``empty_data`` as an array with field names
30-
as keys and submitted values as string values (or arrays if nested fields are
31-
also compound).
29+
If a form is compound, you can set ``empty_data`` as an array, object or
30+
closure. See the :doc:`/form/use_empty_data` article for more details about
31+
these options.
3232
3333
.. note::
3434

0 commit comments

Comments
 (0)