Skip to content

Commit 167adab

Browse files
committed
Rename CollectionType entry options
1 parent 4dd1f25 commit 167adab

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

cookbook/form/form_collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Notice that you embed a collection of ``TagType`` forms using the
126126
{
127127
$builder->add('description');
128128

129-
$builder->add('tags', 'collection', array('type' => new TagType()));
129+
$builder->add('tags', 'collection', array('entry_type' => new TagType()));
130130
}
131131

132132
public function configureOptions(OptionsResolver $resolver)
@@ -285,7 +285,7 @@ add the ``allow_add`` option to your collection field::
285285
$builder->add('description');
286286

287287
$builder->add('tags', 'collection', array(
288-
'type' => new TagType(),
288+
'entry_type' => new TagType(),
289289
'allow_add' => true,
290290
));
291291
}

reference/forms/types/collection.rst

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ forms, which is useful when creating forms that expose one-to-many relationships
1616
| Options | - `allow_add`_ |
1717
| | - `allow_delete`_ |
1818
| | - `delete_empty`_ |
19-
| | - `options`_ |
19+
| | - `entry_options`_ |
2020
| | - `prototype`_ |
2121
| | - `prototype_name`_ |
22-
| | - `type`_ |
22+
| | - `entry_type`_ |
2323
+-------------+-----------------------------------------------------------------------------+
2424
| Inherited | - `by_reference`_ |
2525
| options | - `cascade_validation`_ |
@@ -52,10 +52,10 @@ to an array of email addresses. In the form, you want to expose each email
5252
address as its own input text box::
5353

5454
$builder->add('emails', 'collection', array(
55-
// each item in the array will be an "email" field
56-
'type' => 'email',
55+
// each entry in the array will be an "email" field
56+
'entry_type' => 'email',
5757
// these options are passed to each "email" type
58-
'options' => array(
58+
'entry_options' => array(
5959
'required' => false,
6060
'attr' => array('class' => 'email-box')
6161
),
@@ -266,19 +266,24 @@ form you have to set this option to true. However, existing collection entries
266266
will only be deleted if you have the allow_delete_ option enabled. Otherwise
267267
the empty values will be kept.
268268

269-
options
270-
~~~~~~~
269+
entry_options
270+
~~~~~~~~~~~~~
271+
272+
.. versionadded:: 2.7
273+
The ``entry_options`` option was introduced in Symfony 2.7 in favor of
274+
``options``, which is available prior to 2.7.
271275

272276
**type**: ``array`` **default**: ``array()``
273277

274-
This is the array that's passed to the form type specified in the `type`_
278+
This is the array that's passed to the form type specified in the `entry_type`_
275279
option. For example, if you used the :doc:`choice </reference/forms/types/choice>`
276-
type as your `type`_ option (e.g. for a collection of drop-down menus), then
277-
you'd need to at least pass the ``choices`` option to the underlying type::
280+
type as your `entry_type`_ option (e.g. for a collection of drop-down menus),
281+
then you'd need to at least pass the ``choices`` option to the underlying
282+
type::
278283

279284
$builder->add('favorite_cities', 'collection', array(
280-
'type' => 'choice',
281-
'options' => array(
285+
'entry_type' => 'choice',
286+
'entry_options' => array(
282287
'choices' => array(
283288
'nashville' => 'Nashville',
284289
'paris' => 'Paris',
@@ -336,12 +341,16 @@ If you have several collections in your form, or worse, nested collections
336341
you may want to change the placeholder so that unrelated placeholders are not
337342
replaced with the same value.
338343

339-
type
340-
~~~~
344+
entry_type
345+
~~~~~~~~~~
346+
347+
.. versionadded:: 2.7
348+
The ``entry_type`` option was introduced in Symfony 2.7 in favor of
349+
``type``, which is available prior to 2.7.
341350

342351
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **required**
343352

344-
This is the field type for each item in this collection (e.g. ``text``, ``choice``,
353+
This is the field type for each entry in this collection (e.g. ``text``, ``choice``,
345354
etc). For example, if you have an array of email addresses, you'd use the
346355
:doc:`email </reference/forms/types/email>` type. If you want to embed
347356
a collection of some other form, create a new instance of your form type

0 commit comments

Comments
 (0)