Skip to content

Commit a6724f4

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: Added information about float choice lists tweaks to the contribution chapter Reverted removal, removed API links instead [2.3] Examples that points to the DataCollectorListener should be removed. Conflicts: components/form/form_events.rst
2 parents 42e243c + 7ab6df9 commit a6724f4

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

components/form/form_events.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The ``FormEvents::PRE_SET_DATA`` event is dispatched at the beginning of the
8383
.. sidebar:: ``FormEvents::PRE_SET_DATA`` in the Form component
8484

8585
The ``collection`` form type relies on the
86-
:class:`Symfony\\Component\\Form\\Extension\\Core\\EventListener\\ResizeFormListener`
86+
``Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener``
8787
subscriber, listening to the ``FormEvents::PRE_SET_DATA`` event in order
8888
to reorder the form's fields depending on the data from the pre-populated
8989
object, by removing and adding all form rows.
@@ -113,7 +113,7 @@ the form.
113113
.. versionadded:: 2.4
114114
The data collector extension was introduced in Symfony 2.4.
115115

116-
The :class:`Symfony\\Component\\Form\\Extension\\DataCollector\\EventListener\\DataCollectorListener`
116+
The ``Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener``
117117
class is subscribed to listen to the ``FormEvents::POST_SET_DATA`` event
118118
in order to collect information about the forms from the denormalized
119119
model and view data.
@@ -155,10 +155,10 @@ It can be used to:
155155

156156
.. sidebar:: ``FormEvents::PRE_SUBMIT`` in the Form component
157157

158-
The :class:`Symfony\\Component\\Form\\Extension\\Core\\EventListener\\TrimListener`
158+
The ``Symfony\Component\Form\Extension\Core\EventListener\TrimListener``
159159
subscriber subscribes to the ``FormEvents::PRE_SUBMIT`` event in order to
160160
trim the request's data (for string values).
161-
The :class:`Symfony\\Component\\Form\\Extension\\Csrf\\EventListener\\CsrfValidationListener`
161+
The ``Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener``
162162
subscriber subscribes to the ``FormEvents::PRE_SUBMIT`` event in order to
163163
validate the CSRF token.
164164

@@ -189,7 +189,7 @@ It can be used to change data from the normalized representation of the data.
189189

190190
.. sidebar:: ``FormEvents::SUBMIT`` in the Form component
191191

192-
The :class:`Symfony\\Component\\Form\\Extension\\Core\\EventListener\\ResizeFormListener`
192+
The ``Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener``
193193
subscribes to the ``FormEvents::SUBMIT`` event in order to remove the
194194
fields that need to be removed whenever manipulating a collection of forms
195195
for which ``allow_delete`` has been enabled.
@@ -224,10 +224,10 @@ It can be used to fetch data after denormalization.
224224
.. versionadded:: 2.4
225225
The data collector extension was introduced in Symfony 2.4.
226226

227-
The :class:`Symfony\\Component\\Form\\Extension\\DataCollector\\EventListener\\DataCollectorListener`
227+
The ``Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener``
228228
subscribes to the ``FormEvents::POST_SUBMIT`` event in order to collect
229229
information about the forms.
230-
The :class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener`
230+
The ``Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener``
231231
subscribes to the ``FormEvents::POST_SUBMIT`` event in order to
232232
automatically validate the denormalized object, and update the normalized
233233
as well as the view's representations.

contributing/documentation/format.rst

+5-14
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,15 @@ roles to the standard reST markup. Read more about the `Sphinx Markup Constructs
3333
Syntax Highlighting
3434
~~~~~~~~~~~~~~~~~~~
3535

36-
PHP is the default syntax highlight applied to all code blocks. You can change
37-
it with the ``code-block`` directive:
36+
PHP is the default syntax highlighter applied to all code blocks. You can
37+
change it with the ``code-block`` directive:
3838

3939
.. code-block:: rst
4040
4141
.. code-block:: yaml
4242
4343
{ foo: bar, bar: { foo: bar, bar: baz } }
4444
45-
If your PHP code begins with ``<?php``, then you need to use ``html+php`` as
46-
the name of the highlighted syntax:
47-
48-
.. code-block:: rst
49-
50-
.. code-block:: html+php
51-
52-
<?php echo $this->foobar(); ?>
53-
5445
.. note::
5546

5647
Besides all of the major programming languages, the syntax highlighter
@@ -183,7 +174,7 @@ If you're documenting a brand new feature or a change that's been made in
183174
Symfony, you should precede your description of the change with a
184175
``.. versionadded:: 2.X`` directive and a short description:
185176

186-
.. code-block:: text
177+
.. code-block:: rst
187178
188179
.. versionadded:: 2.3
189180
The ``askHiddenResponse`` method was introduced in Symfony 2.3.
@@ -193,7 +184,7 @@ Symfony, you should precede your description of the change with a
193184
If you're documenting a behavior change, it may be helpful to *briefly* describe
194185
how the behavior has changed.
195186

196-
.. code-block:: text
187+
.. code-block:: rst
197188
198189
.. versionadded:: 2.3
199190
The ``include()`` function is a new Twig feature that's available in
@@ -204,7 +195,7 @@ a new branch of the documentation is created from the ``master`` branch.
204195
At this point, all the ``versionadded`` tags for Symfony versions that have
205196
reached end-of-life will be removed. For example, if Symfony 2.5 were released
206197
today, and 2.2 had recently reached its end-of-life, the 2.2 ``versionadded``
207-
tags would be removed from the new 2.5 branch.
198+
tags would be removed from the new ``2.5`` branch.
208199

209200
Testing Documentation
210201
~~~~~~~~~~~~~~~~~~~~~

contributing/documentation/overview.rst

+16-11
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Contributing to the Documentation
33

44
One of the essential principles of the Symfony project is that **documentation is
55
as important as code**. That's why a great amount of resources are dedicated to
6-
documenting new features and to keeping the rest of the documentation up to date.
6+
documenting new features and to keeping the rest of the documentation up-to-date.
77

8-
More than 800 developers all around the world have contributed to Symfony's
9-
documentation, and we are glad that you are considering joining this big family.
8+
More than 700 developers all around the world have contributed to Symfony's
9+
documentation and we are glad that you are considering joining this big family.
1010
This guide will explain everything you need to contribute to the Symfony
1111
documentation.
1212

@@ -27,9 +27,9 @@ Before Your First Contribution
2727
Your First Documentation Contribution
2828
-------------------------------------
2929

30-
In this section you'll learn how to contribute to the Symfony documentation for
30+
In this section, you'll learn how to contribute to the Symfony documentation for
3131
the first time. The next section will explain the shorter process you'll follow
32-
in the future for every contribution after your first.
32+
in the future for every contribution after your first one.
3333

3434
Let's imagine that you want to improve the installation chapter of the Symfony
3535
book. In order to make your changes, follow these steps:
@@ -164,8 +164,12 @@ Now you can **sync your fork** by executing the following command:
164164
165165
$ cd projects/symfony-docs/
166166
$ git fetch upstream
167-
$ git checkout master
168-
$ git merge upstream/master
167+
$ git checkout 2.3
168+
$ git merge upstream/2.3
169+
170+
This command will update the ``2.3`` branch, which is the one you used to
171+
create the new branch for your changes. If have used another base branch,
172+
e.g. ``master``, replace the ``2.3`` with the appropriate branch name.
169173

170174
Great! Now you can proceed by following the same steps explained in the previous
171175
section:
@@ -212,8 +216,8 @@ steps to contribute to the Symfony documentation, which you can use as a
212216
# sync your fork with the official Symfony repository
213217
$ cd projects/symfony-docs/
214218
$ git fetch upstream
215-
$ git checkout master
216-
$ git merge upstream/master
219+
$ git checkout 2.3
220+
$ git merge upstream/2.3
217221
218222
# create a new branch from the oldest maintained version
219223
$ git checkout 2.3
@@ -262,10 +266,11 @@ Why Should I Use the Oldest Maintained Branch Instead of the Master Branch?
262266

263267
Consistent with Symfony's source code, the documentation repository is split
264268
into multiple branches, corresponding to the different versions of Symfony itself.
265-
The master branch holds the documentation for the development branch of the code.
269+
The ``master`` branch holds the documentation for the development branch of
270+
the code.
266271

267272
Unless you're documenting a feature that was introduced after Symfony 2.3,
268-
your changes should always be based on the 2.3 branch. Documentation managers
273+
your changes should always be based on the ``2.3`` branch. Documentation managers
269274
will use the necessary Git-magic to also apply your changes to all the active
270275
branches of the documentation.
271276

reference/forms/types/choice.rst

+19
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ is the item value and the array value is the item's label::
9393
'choices' => array('m' => 'Male', 'f' => 'Female')
9494
));
9595

96+
.. tip::
97+
98+
When the values to choose from are not integers or strings (but e.g. floats
99+
or booleans), you should use the `choice_list`_ option instead. With this
100+
option you are able to keep the original data format which is important
101+
to ensure that the user input is validated properly and useless database
102+
updates caused by a data type mismatch are avoided.
103+
96104
choice_list
97105
~~~~~~~~~~~
98106

@@ -103,6 +111,17 @@ The ``choice_list`` option must be an instance of the ``ChoiceListInterface``.
103111
For more advanced cases, a custom class that implements the interface
104112
can be created to supply the choices.
105113

114+
With this option you can also allow float values to be selected as data.
115+
116+
.. code-block:: php
117+
118+
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
119+
120+
// ...
121+
$builder->add('status', 'choice', array(
122+
'choice_list' => new ChoiceList(array(1, 0.5), array('Full', 'Half')
123+
));
124+
106125
.. include:: /reference/forms/types/options/empty_value.rst.inc
107126

108127
.. include:: /reference/forms/types/options/expanded.rst.inc

0 commit comments

Comments
 (0)