8000 Merge branch '2.3' into 2.7 · symfony/symfony-docs@11033bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 11033bd

Browse files
committed
Merge branch '2.3' into 2.7
2 parents 9231f92 + 504a8f9 commit 11033bd

File tree

10 files changed

+149
-62
lines changed

10 files changed

+149
-62
lines changed

book/controller.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ session.
619619
Flash Messages
620620
~~~~~~~~~~~~~~
621621

622-
You can also store small messages that will be stored on the user's session
623-
for exactly one additional request. This is useful when processing a form:
622+
You can also store small messages that will be stored on the user's session.
623+
This is useful when processing a form:
624624
you want to redirect and have a special message shown on the *next* page.
625625
These types of messages are called "flash" messages.
626626

@@ -675,9 +675,17 @@ the ``notice`` message:
675675
</div>
676676
<?php endforeach ?>
677677

678-
By design, flash messages are meant to live for exactly one request (they're
679-
"gone in a flash"). They're designed to be used across redirects exactly as
680-
you've done in this example.
678+
.. note::
679+
680+
By design, flash messages are meant to be processed exactly once. This means
681+
that they vanish from the session automatically when they are retrieved from
682+
the flash bag by calling the ``get()`` method.
683+
684+
.. tip::
685+
686+
You can use the
687+
:method:`Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface::peek`
688+
method instead to retrieve the message while keeping it in the bag.
681689

682690
.. index::
683691
single: Controller; Response object

book/forms.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,21 @@ controller::
232232
$form->handleRequest($request);
233233

234234
if ($form->isValid()) {
235-
// perform some action, such as saving the task to the database
235+
// ... perform some action, such as saving the task to the database
236236

237237
return $this->redirectToRoute('task_success');
238238
}
239239

240-
// ...
240+
return $this->render('default/new.html.twig', array(
241+
'form' => $form->createView(),
242+
));
241243
}
244+
245+
.. caution::
246+
247+
Be aware that the ``createView()`` method should be called *after* ``handleRequest``
248+
is called. Otherwise, changes done in the ``*_SUBMIT`` events aren't applied to the
249+
view (like validation errors).
242250

243251
.. versionadded:: 2.3
244252
The :method:`Symfony\\Component\\Form\\FormInterface::handleRequest` method

components/console/introduction.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ Coloring the Output
143143
By default, the Windows command console doesn't support output coloring. The
144144
Console component disables output coloring for Windows systems, but if your
145145
commands invoke other scripts which emit color sequences, they will be
146-
wrongly displayed as raw escape characters. Install the `ConEmu`_ or `ANSICON`_
147-
free applications to add coloring support to your Windows command console.
146+
wrongly displayed as raw escape characters. Install the `ConEmu`_, `ANSICON`_
147+
or `Mintty`_ (used by default in GitBash and Cygwin) free applications
148+
to add coloring support to your Windows command console.
148149

149150
Whenever you output text, you can surround the text with tags to color its
150151
output. For example::
@@ -582,3 +583,4 @@ Learn More!
582583
.. _Packagist: https://packagist.org/packages/symfony/console
583584
.. _ConEmu: https://code.google.com/p/conemu-maximus5/
584585
.. _ANSICON: https://github.com/adoxa/ansicon/releases
586+
.. _Mintty: https://mintty.github.io/

contributing/code/tests.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ what's going on and if the tests are broken because of the new code.
5151
5252
.. tip::
5353

54-
On Windows, install the `ConEmu`_ or `ANSICON`_ free applications to see
55-
colored test results.
54+
On Windows, install the `ConEmu`_, `ANSICON`_ or `Mintty`_ free applications
55+
to see colored test results.
5656

5757
.. _ConEmu: https://code.google.com/p/conemu-maximus5/
5858
.. _ANSICON: https://github.com/adoxa/ansicon/releases
59+
.. _Mintty: https://mintty.github.io/

contributing/documentation/overview.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ page on GitHub and click on ``Details``.
269269
``.platform.app.yaml``, ``.platform/services.yaml`` and
270270
``.platform/routes.yaml`` allow `Platform.sh`_ to build Pull Requests.
271271

272+
.. note::
273+
274+
Only Pull Requests to maintained branches are automatically built by
275+
Platform.sh. Check the `roadmap`_ for maintained branches.
276+
272277
Minor Changes (e.g. Typos)
273278
--------------------------
274279

@@ -345,4 +350,5 @@ definitely don't want you to waste your time!
345350
.. _SensioLabsConnect: https://connect.sensiolabs.com/
346351
.. _`Symfony Documentation Badge`: https://connect.sensiolabs.com/badge/36/symfony-documentation-contributor
347352
.. _`sync your fork`: https://help.github.com/articles/syncing-a-fork
348-
.. _`Platform.sh`: https://platform.sh
353+
.. _`Platform.sh`: https://platform.sh
354+
.. _`roadmap`: https://symfony.com/roadmap

cookbook/email/dev_environment.rst

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ will not be sent when you run tests, but will continue to be sent in the
3333
.. code-block:: xml
3434
3535
<!-- app/config/config_test.xml -->
36-
37-
<!--
36+
<?xml version="1.0" encoding="UTF-8" ?>
37+
<container xmlns="http://symfony.com/schema/dic/services"
38+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3839
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
39-
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
40-
-->
40+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
41+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
4142
42-
<swiftmailer:config
43-
disable-delivery="true" />
43+
<swiftmailer:config disable-delivery="true" />
44+
</container>
4445
4546
.. code-block:: php
4647
@@ -70,13 +71,15 @@ via the ``delivery_address`` option:
7071
.. code-block:: xml
7172
7273
<!-- app/config/config_dev.xml -->
73-
74-
<!--
74+
<?xml version="1.0" encoding="UTF-8" ?>
75+
<container xmlns="http://symfony.com/schema/dic/services"
76+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7577
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
76-
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
77-
-->
78+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
79+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
7880
79-
<swiftmailer:config delivery-address="dev@example.com" />
81+
<swiftmailer:config delivery-address="dev@example.com" />
82+
</container>
8083
8184
.. code-block:: php
8285
@@ -140,27 +143,32 @@ by adding the ``delivery_whitelist`` option:
140143
delivery_whitelist:
141144
# all email addresses matching this regex will *not* be
142145
# redirected to dev@example.com
143-
- "/@specialdomain\.com$/"
146+
- '/@specialdomain\.com$/'
144147
145148
# all emails sent to admin@mydomain.com won't
146149
# be redirected to dev@example.com too
147-
- "/^admin@mydomain\.com$/"
150+
- '/^admin@mydomain\.com$/'
148151
149152
.. code-block:: xml
150153
151154
<!-- app/config/config_dev.xml -->
152155
153156
<?xml version="1.0" charset="UTF-8" ?>
157+
<?xml version="1.0" encoding="UTF-8" ?>
154158
<container xmlns="http://symfony.com/schema/dic/services"
155-
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer">
159+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
160+
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
161+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
162+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
156163
157-
<swiftmailer:config delivery-address="dev@example.com">
158-
<!-- all email addresses matching this regex will *not* be redirected to dev@example.com -->
159-
<swiftmailer:delivery-whitelist-pattern>/@specialdomain\.com$/</swiftmailer:delivery-whitelist-pattern>
164+
<swiftmailer:config delivery-address="dev@example.com">
165+
<!-- all email addresses matching this regex will *not* be redirected to dev@example.com -->
166+
<swiftmailer:delivery-whitelist-pattern>/@specialdomain\.com$/</swiftmailer:delivery-whitelist-pattern>
160167
161-
<!-- all emails sent to admin@mydomain.com won't be redirected to dev@example.com too -->
162-
<swiftmailer:delivery-whitelist-pattern>/^admin@mydomain\.com$/</swiftmailer:delivery-whitelist-pattern>
163 10000 -
</swiftmailer:config>
168+
<!-- all emails sent to admin@mydomain.com won't be redirected to dev@example.com too -->
169+
<swiftmailer:delivery-whitelist-pattern>/^admin@mydomain\.com$/</swiftmailer:delivery-whitelist-pattern>
170+
</swiftmailer:config>
171+
</container>
164172
165173
.. code-block:: php
166174

cookbook/email/email.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ already included:
4141
.. code-block:: xml
4242
4343
<!-- app/config/config.xml -->
44-
45-
<!--
44+
<?xml version="1.0" encoding="UTF-8" ?>
45+
<container xmlns="http://symfony.com/schema/dic/services"
46+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4647
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
47-
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
48-
-->
49-
50-
<swiftmailer:config
51-
transport="%mailer_transport%"
52-
host="%mailer_host%"
53-
username="%mailer_user%"
54-
password="%mailer_password%" />
48+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
49+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
50+
51+
<swiftmailer:config
52+
transport="%mailer_transport%"
53+
host="%mailer_host%"
54+
username="%mailer_user%"
55+
password="%mailer_password%"
56+
/>
57+
</container>
5558
5659
.. code-block:: php
5760

cookbook/email/spool.rst

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ swiftmailer with the memory option, use the following configuration:
3535
.. code-block:: xml
3636
3737
<!-- app/config/config.xml -->
38-
39-
<!--
38+
<?xml version="1.0" encoding="UTF-8" ?>
39+
<container xmlns="http://symfony.com/schema/dic/services"
40+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4041
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
41-
http://symfony.com/schema/dic/swiftmailer
42-
http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
43-
-->
42+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
43+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
4444
45-
<swiftmailer:config>
46-
<swiftmailer:spool type="memory" />
47-
</swiftmailer:config>
45+
<swiftmailer:config>
46+
<swiftmailer:spool type="memory" />
47+
</swiftmailer:config>
48+
</container>
4849
4950
.. code-block:: php
5051
@@ -73,18 +74,20 @@ In order to use the spool with a file, use the following configuration:
7374
.. code-block:: xml
7475
7576
<!-- app/config/config.xml -->
76-
77-
<!--
77+
<?xml version="1.0" encoding="UTF-8" ?>
78+
<container xmlns="http://symfony.com/schema/dic/services"
79+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7880
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
79-
http://symfony.com/schema/dic/swiftmailer
80-
http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
81-
-->
82-
83-
<swiftmailer:config>
84-
<swiftmailer:spool
85-
type="file"
86-
path="/path/to/spool" />
87-
</swiftmailer:config>
81+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
82+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
83+
84+
<swiftmailer:config>
85+
<swiftmailer:spool
86+
type="file"
87+
path="/path/to/spool"
88+
/>
89+
</swiftmailer:config>
90+
</container>
8891
8992
.. code-block:: php
9093

cookbook/form/form_collections.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ great, your user can't actually add any new tags yet.
262262
.. _cookbook-form-collections-new-prototype:
263263

264264
Allowing "new" Tags with the "Prototype"
265-
-----------------------------------------
265+
----------------------------------------
266266

267267
Allowing the user to dynamically add new tags means that you'll need to
268268
use some JavaScript. Previously you added two tags to your form in the controller.
@@ -417,6 +417,11 @@ into new ``Tag`` objects and added to the ``tags`` property of the ``Task`` obje
417417

418418
You can find a working example in this `JSFiddle`_.
419419

420+
.. seealso::
421+
422+
If you want to customize the HTML code in the prototype, read
423+
:ref:`cookbook-form-custom-prototype`.
424+
420425
To make handling these new tags easier, add an "adder" and a "remover" method
421426
for the tags in the ``Task`` class::
422427

cookbook/form/form_customization.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,49 @@ You can also override the markup for an entire field row using the same method:
739739
<?php echo $view['form']->widget($form) ?>
740740
</div>
741741

742+
.. _cookbook-form-custom-prototype:
743+
744+
How to Customize a Collection Prototype
745+
---------------------------------------
746+
747+
When using a :doc:`collection of forms </cookbook/form/form_collections>`,
748+
the prototype can be overridden with a completely custom prototype by
749+
overriding a block. For example, if your form field is named ``tasks``, you
750+
will be able to change the widget for each task as follows:
751+
752+
.. configuration-block::
753+
754+
.. code-block:: html+jinja
755+
756+
{% form_theme form _self %}
757+
758+
{% block _tasks_entry_widget %}
759+
<tr>
760+
<td>{{ form_widget(task.task) }}</td>
761+
<td>{{ form_widget(task.dueDate) }}</td>
762+
</tr>
763+
{% endblock %}
764+
765+
.. code-block:: html+php
766+
767+
<!-- src/AppBundle/Resources/views/Form/_tasks_entry_widget.html.php -->
768+
<tr>
769+
<td><?php echo $view['form']->widget($form->task) ?></td>
770+
<td><?php echo $view['form']->widget($form->dueDate) ?></td>
771+
</tr>
772+
773+
Not only can you override the rendered widget, but you can also change the
774+
complete form row or the label as well. For the ``tasks`` field given above,
775+
the block names would be the following:
776+
777+
================ =======================
778+
Part of the Form Block Name
779+
================ =======================
780+
``label`` ``_tasks_entry_label``
781+
``widget`` ``_tasks_entry_widget``
782+
``row`` ``_tasks_entry_row``
783+
================ =======================
784+
742785
Other common Customizations
743786
---------------------------
744787

0 commit comments

Comments
 (0)
0