Skip to content

Commit 2fa596e

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: Added a note about PHP extension and Symfony Form types extension Update choice_label docs to match given examples Improved the explanation of the block_name form option [Diversity] Add Voting Logic Examples
2 parents dbce4a5 + 5a4a8fc commit 2fa596e

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

contributing/diversity/governance.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ For an actionable item to pass, approval from greater than 50% of the voting
7272
guidance team members is required. Use or management of finances/donations
7373
require at least a two-thirds majority to pass.
7474

75+
For transparency and ease-of-understanding, this means only the following
76+
combinations of votes will result in an actionable item passing:
77+
78+
+-----+---------+---------+
79+
| For | Against | Abstain |
80+
+=====+=========+=========+
81+
| 5 | 0 | 0 |
82+
+-----+---------+---------+
83+
| 4 | 1 | 0 |
84+
+-----+---------+---------+
85+
| 3 | 2 | 0 |
86+
+-----+---------+---------+
87+
| 4 | 0 | 1 |
88+
+-----+---------+---------+
89+
| 3 | 1 | 1 |
90+
+-----+---------+---------+
91+
7592
Guidance Principles
7693
-------------------
7794

form/create_custom_field_type.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Defining the Field Type
1616
In order to create the custom field type, first you have to create the class
1717
representing the field. In this situation the class holding the field type
1818
will be called ``ShippingType`` and the file will be stored in the default location
19-
for form fields, which is ``App\Form\Type``. Make sure the field extends
20-
:class:`Symfony\\Component\\Form\\AbstractType`::
19+
for form fields, which is ``App\Form\Type``.
20+
21+
All field types must implement the :class:`Symfony\\Component\\Form\\FormTypeInterface`,
22+
but you should instead extend from :class:`Symfony\\Component\\Form\\AbstractType`,
23+
which already implements that interface and provides some utilities::
2124

2225
// src/Form/Type/ShippingType.php
2326
namespace App\Form\Type;
@@ -53,8 +56,17 @@ for form fields, which is ``App\Form\Type``. Make sure the field extends
5356
Here, the return value of the ``getParent()`` function indicates that you're
5457
extending the ``ChoiceType`` field. This means that, by default, you inherit
5558
all of the logic and rendering of that field type. To see some of the logic,
56-
check out the `ChoiceType`_ class. There are three methods that are particularly
57-
important:
59+
check out the `ChoiceType`_ class.
60+
61+
.. note::
62+
63+
The PHP class extension mechanism and the Symfony form field extension
64+
mechanism are not the same. The parent type returned in ``getParent()`` is
65+
what Symfony uses to build and manage the field type. Making the PHP class
66+
extend from ``AbstractType`` is only a convenience way of implementing the
67+
required ``FormTypeInterface``.
68+
69+
There are three methods that are particularly important:
5870

5971
.. _form-type-methods-explanation:
6072

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ block_name
44
**type**: ``string`` **default**: the form's name (see :ref:`Knowing which
55
block to customize <form-customization-sidebar>`)
66
7-
Allows you to override the block name used to render the form type.
8-
Useful for example if you have multiple instances of the same form and you
9-
need to personalize the rendering of the forms individually.
7+
Allows you to add a custom block name to the ones used by default to render the
8+
form type. Useful for example if you have multiple instances of the same form
9+
and you need to personalize the rendering of the forms individually.
10+
11+
If you set for example this option to ``my_custom_name`` and the field is of
12+
type ``text``, Symfony will use the following names (and in this order) to find
13+
the block used to render the widget of the field: ``_my_custom_name_widget``,
14+
``text_widget`` and ``form_widget``.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ more control::
1616
'no' => false,
1717
'maybe' => null,
1818
],
19-
'choice_label' => function ($choiceValue, $key, $value) {
20-
if ($value == $choiceValue) {
19+
'choice_label' => function ($value, $key, $choiceValue) {
20+
if (true === $value) {
2121
return 'Definitely!';
2222
}
2323

@@ -28,9 +28,9 @@ more control::
2828
},
2929
]);
3030

31-
This method is called for *each* choice, passing you the choice ``$value`` and the
32-
``$key`` from the choices array (``$index`` is related to `choice_value`_). This
33-
will give you:
31+
This method is called for *each* choice, passing you the ``$value`` and
32+
``$key`` from the choices array (additional ``$choiceValue`` is related to `choice_value`_).
33+
This will give you:
3434

3535
.. image:: /_images/reference/form/choice-example2.png
3636
:align: center

0 commit comments

Comments
 (0)