-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Improvements of the CollectionType Documentation #3338
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,14 @@ forms, which is useful when creating forms that expose one-to-many relationships | |
| | - `allow_delete`_ | | ||
| | - `prototype`_ | | ||
| | - `prototype_name`_ | | ||
| | - `delete_empty`_ | | ||
+-------------+-----------------------------------------------------------------------------+ | ||
| Inherited | - `label`_ | | ||
| options | - `error_bubbling`_ | | ||
| | - `error_mapping`_ | | ||
| | - `by_reference`_ | | ||
| | - `empty_data`_ | | ||
| | - `required`_ | | ||
| | - `mapped`_ | | ||
+-------------+-----------------------------------------------------------------------------+ | ||
| Parent type | :doc:`form </reference/forms/types/form>` | | ||
|
@@ -34,9 +36,9 @@ forms, which is useful when creating forms that expose one-to-many relationships | |
|
||
.. note:: | ||
|
||
If you are working with a collection of Doctrine entities, pay special | ||
If you are working with a collection of Doctrine entities, pay special | ||
attention to the `allow_add`_, `allow_delete`_ and `by_reference`_ options. | ||
You can also see a complete example in the cookbook article | ||
You can also see a complete example in the cookbook article | ||
:doc:`/cookbook/form/form_collections`. | ||
|
||
Basic Usage | ||
|
@@ -333,6 +335,16 @@ If you have several collections in your form, or worse, nested collections | |
you may want to change the placeholder so that unrelated placeholders are not | ||
replaced with the same value. | ||
|
||
delete_empty | ||
~~~~~~~~~~~~~~ | ||
|
||
**type**: ``Boolean`` **default**: ``false`` | ||
|
||
If you want to explicitly remove entirely empty collection entries from your | ||
form you have to set this option to true. Existing collection entries will | ||
however only be deleted if you have `allow_delete`_ option enabled, otherwise | ||
the empty values will be kept. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rewrite this a bit:
|
||
|
||
Inherited options | ||
----------------- | ||
|
||
|
@@ -357,3 +369,5 @@ error_bubbling | |
.. include:: /reference/forms/types/options/by_reference.rst.inc | ||
|
||
.. include:: /reference/forms/types/options/empty_data.rst.inc | ||
|
||
.. include:: /reference/forms/types/options/required.rst.inc |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,13 @@ choice is selected. | |
|
||
The true default value of this option depends on the field options: | ||
|
||
* If ``compound`` is ``true`` and ``data_class`` is set, then ``new $data_class()``; | ||
* If ``compound`` is ``true`` and no ``data_class`` is set, then ``array()``; | ||
* If ``compound`` is ``false``, then ``null``. | ||
* If ``required`` is ``true`` and ``data_class`` is set, then ``new $data_class()``; | ||
* If ``required`` is ``true`` and no ``data_class`` is set, then ``array()``; | ||
* If ``required`` is ``false``, then ``null``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure this is right, it looks to me (depending on the situation) that both Let me know what you see :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @weaverryan is right. So, this part should be. But I'm not sure if we need a table with eight (each possible combination of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think a table is the right choice here, just:
|
||
|
||
.. tip:: | ||
|
||
The ``compound`` option is set to ``true`` when the field actually represents | ||
a collection of fields (e.g. a form of fields). | ||
|
||
For example, if you want the ``gender`` field to be set to ``null`` when no | ||
value is selected, you can do it like this: | ||
But you can customize this to your needs. For example, if you want the ``gender`` field to be | ||
set to explicitly ``null`` when no value is selected, you can do it like this: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [...] to be explicitly set to |
||
|
||
.. code-block:: php | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,9 @@ This is superficial and independent from validation. At best, if you let Symfony | |
guess your field type, then the value of this option will be guessed from | ||
your validation information. | ||
|
||
.. _`HTML5 required attribute`: http://diveintohtml5.info/forms.html | ||
.. _`HTML5 required attribute`: http://diveintohtml5.info/forms.html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add the note before this, such that external links are always the last elements in a file |
||
|
||
.. note:: | ||
|
||
The required option does also affect the way how empty data of your form is | ||
being handled. For further details check the :doc:` empty_data</reference/forms/types/options/empty_data.rst.inc>` option. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be indented by 4 spaces and you should wrap the lines around the 72th character and the space before `empty_data`_ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and, at last, always add a new line feed at the end of a file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tagline should be as long as the headline (remove 2 ~s)