Skip to content

Commit 1b00278

Browse files
wouterjweaverryan
authored andcommitted
Rename CollectionType entry options
1 parent 622b149 commit 1b00278

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

Diff for: cookbook/form/form_collections.rst

+2-2
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
}

Diff for: reference/forms/types/collection.rst

+30-22
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ photos).
1717
| Options | - `allow_add`_ |
1818
| | - `allow_delete`_ |
1919
| | - `delete_empty`_ |
20-
| | - `options`_ |
20+
| | - `entry_options`_ |
21+
| | - `entry_type`_ |
2122
| | - `prototype`_ |
2223
| | - `prototype_name`_ |
23-
| | - `type`_ |
2424
+-------------+-----------------------------------------------------------------------------+
2525
| Inherited | - `by_reference`_ |
2626
| options | - `cascade_validation`_ |
@@ -53,10 +53,10 @@ to an array of email addresses. In the form, you want to expose each email
5353
address as its own input text box::
5454

5555
$builder->add('emails', 'collection', array(
56-
// each item in the array will be an "email" field
57-
'type' => 'email',
56+
// each entry in the array will be an "email" field
57+
'entry_type' => 'email',
5858
// these options are passed to each "email" type
59-
'options' => array(
59+
'entry_options' => array(
6060
'required' => false,
6161
'attr' => array('class' => 'email-box')
6262
),
@@ -273,20 +273,24 @@ form you have to set this option to true. However, existing collection entries
273273
will only be deleted if you have the allow_delete_ option enabled. Otherwise
274274
the empty values will be kept.
275275

276-
options
277-
~~~~~~~
276+
entry_options
277+
~~~~~~~~~~~~~
278+
279+
.. versionadded:: 2.7
280+
The ``entry_options`` option was introduced in Symfony 2.7 in favor of
281+
``options``, which is available prior to 2.7.
278282

279283
**type**: ``array`` **default**: ``array()``
280284

281-
This is the array that's passed to the form type specified in the `type`_
285+
This is the array that's passed to the form type specified in the `entry_type`_
282286
option. For example, if you used the :doc:`choice </reference/forms/types/choice>`
283-
type as your `type`_ option (e.g. for a collection of drop-down menus),
287+
type as your `entry_type`_ option (e.g. for a collection of drop-down menus),
284288
then you'd need to at least pass the ``choices`` option to the underlying
285289
type::
286290

287291
$builder->add('favorite_cities', 'collection', array(
288-
'type' => 'choice',
289-
'options' => array(
292+
'entry_type' => 'choice',
293+
'entry_options' => array(
290294
'choices' => array(
291295
'nashville' => 'Nashville',
292296
'paris' => 'Paris',
@@ -296,6 +300,21 @@ type::
296300
),
297301
));
298302

303+
entry_type
304+
~~~~~~~~~~
305+
306+
.. versionadded:: 2.7
307+
The ``entry_type`` option was introduced in Symfony 2.7 in favor of
308+
``type``, which is available prior to 2.7.
309+
310+
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **required**
311+
312+
This is the field type for each item in this collection (e.g. ``text``,
313+
``choice``, etc). For example, if you have an array of email addresses,
314+
you'd use the :doc:`email </reference/forms/types/email>` type. If you want
315+
to embed a collection of some other form, create a new instance of your
316+
form type and pass it as this option.
317+
299318
prototype
300319
~~~~~~~~~
301320

@@ -344,17 +363,6 @@ If you have several collections in your form, or worse, nested collections
344363
you may want to change the placeholder so that unrelated placeholders are
345364
not replaced with the same value.
346365

347-
type
348-
~~~~
349-
350-
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **required**
351-
352-
This is the field type for each item in this collection (e.g. ``text``,
353-
``choice``, etc). For example, if you have an array of email addresses,
354-
you'd use the :doc:`email </reference/forms/types/email>` type. If you want
355-
to embed a collection of some other form, create a new instance of your
356-
form type and pass it as this option.
357-
358366
Inherited Options
359367
-----------------
360368

0 commit comments

Comments
 (0)