Skip to content

Commit b163920

Browse files
committed
Merge branch '2.3' into 2.7
Conflicts: cookbook/form/dynamic_form_modification.rst cookbook/form/form_customization.rst
2 parents b3368c2 + 71b9811 commit b163920

23 files changed

+153
-160
lines changed

book/doctrine.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
953953
products:
954954
targetEntity: Product
955955
mappedBy: category
956-
# don't forget to init the collection in the __construct() method
957-
# of the entity
956+
# Don't forget to initialize the collection in
957+
# the __construct() method of the entity
958958
959959
.. code-block:: xml
960960
@@ -1096,7 +1096,7 @@ table, and ``product.category_id`` column, and new foreign key:
10961096
10971097
.. note::
10981098

1099-
This task should only be really used during development. For a more robust
1099+
This command should only be used during development. For a more robust
11001100
method of systematically updating your production database, read about
11011101
`migrations`_.
11021102

@@ -1187,7 +1187,7 @@ You can also query in the other direction::
11871187
// ...
11881188
}
11891189

1190-
In this case, the same things occurs: you first query out for a single ``Category``
1190+
In this case, the same things occur: you first query out for a single ``Category``
11911191
object, and then Doctrine makes a second query to retrieve the related ``Product``
11921192
objects, but only once/if you ask for them (i.e. when you call ``->getProducts()``).
11931193
The ``$products`` variable is an array of all ``Product`` objects that relate

book/forms.rst

+11-6
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ Handling Form Submissions
212212

213213
The second job of a form is to translate user-submitted data back to the
214214
properties of an object. To make this happen, the submitted data from the
215-
user must be written into the form. Add the following functionality to your
216-
controller::
215+
user must be written into the Form object. Add the following functionality to
216+
your controller::
217217

218218
// ...
219219
use Symfony\Component\HttpFoundation\Request;
@@ -683,9 +683,14 @@ the documentation for each type.
683683
The most common option is the ``required`` option, which can be applied to
684684
any field. By default, the ``required`` option is set to ``true``, meaning
685685
that HTML5-ready browsers will apply client-side validation if the field
686-
is left blank. If you don't want this behavior, either set the ``required``
687-
option on your field to ``false`` or
688-
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`.
686+
is left blank. If you don't want this behavior, either
687+
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`
688+
or set the ``required`` option on your field to ``false``::
689+
690+
->add('dueDate', 'date', array(
691+
'widget' => 'single_text',
692+
'required' => false
693+
))
689694

690695
Also note that setting the ``required`` option to ``true`` will **not**
691696
result in server-side validation to be applied. In other words, if a
@@ -924,7 +929,7 @@ specify it:
924929

925930
Some field types have additional rendering options that can be passed
926931
to the widget. These options are documented with each type, but one common
927-
options is ``attr``, which allows you to modify attributes on the form element.
932+
option is ``attr``, which allows you to modify attributes on the form element.
928933
The following would add the ``task_field`` class to the rendered input text
929934
field:
930935

book/templating.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ First, build a base layout file:
201201
<!DOCTYPE html>
202202
<html>
203203
<head>
204-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
204+
<meta charset="UTF-8">
205205
<title>{% block title %}Test Application{% endblock %}</title>
206206
</head>
207207
<body>
@@ -226,7 +226,7 @@ First, build a base layout file:
226226
<!DOCTYPE html>
227227
<html>
228228
<head>
229-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
229+
<meta charset="UTF-8">
230230
<title><?php $view['slots']->output('title', 'Test Application') ?></title>
231231
</head>
232232
<body>
@@ -311,7 +311,7 @@ output might look like this:
311311
<!DOCTYPE html>
312312
<html>
313313
<head>
314-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
314+
<meta charset="UTF-8">
315315
<title>My cool blog posts</title>
316316
</head>
317317
<body>

contributing/code/patches.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ work:
116116
* ``2.3``, if you are fixing a bug for an existing feature (you may have
117117
to choose a higher branch if the feature you are fixing was introduced
118118
in a later version);
119-
* ``2.8``, if you are adding a new feature which is backward compatible;
120-
* ``master``, if you are adding a new and backward incompatible feature.
119+
* ``master``, if you are adding a new feature.
121120

122121
.. note::
123122

cookbook/form/dynamic_form_modification.rst

+8-6
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,15 @@ it with :ref:`dic-tags-form-type`.
403403
.. code-block:: php
404404
405405
// app/config/config.php
406-
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
407-
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
408-
$container->setDefinition(
409-
'app.form.friend_message',
410-
$definition,
411-
array('security.token_storage')
406+
use Symfony\Component\DependencyInjection\Reference;
407+
408+
$definition = new Definition(
409+
'AppBundle\Form\Type\FriendMessageFormType',
410+
array(new Reference('security.token_storage'))
412411
);
412+
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
413+
414+
$container->setDefinition('app.form.friend_message', $definition);
413415
414416
If you wish to create it from within a service that has access to the form factory,
415417
you then use::

cookbook/form/form_customization.rst

+31-21
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ directly in the template that's actually rendering the form.
258258

259259
.. code-block:: html+twig
260260

261-
{% extends '::base.html.twig' %}
261+
{% extends 'base.html.twig' %}
262262

263263
{% form_theme form _self %}
264264

@@ -297,7 +297,7 @@ can now re-use the form customization across many templates:
297297

298298
.. code-block:: html+twig
299299

300-
{# app/Resources/views/Form/fields.html.twig #}
300+
{# app/Resources/views/form/fields.html.twig #}
301301
{% block integer_widget %}
302302
<div class="integer_widget">
303303
{% set type = type|default('number') %}
@@ -313,7 +313,7 @@ tell Symfony to use the template via the ``form_theme`` tag:
313313

314314
.. code-block:: html+twig
315315

316-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
316+
{% form_theme form 'form/fields.html.twig' %}
317317

318318
{{ form_widget(form.age) }}
319319

@@ -329,13 +329,12 @@ name of all the templates as an array using the ``with`` keyword:
329329

330330
.. code-block:: html+twig
331331

332-
{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
333-
'AppBundle:Form:fields.html.twig'] %}
332+
{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] %}
334333

335334
{# ... #}
336335

337-
The templates can be located at different bundles and they can even be stored
338-
at the global ``app/Resources/views/`` directory.
336+
The templates can also be located in different bundles, use the functional name
337+
to reference these templates, e.g. ``AcmeFormExtraBundle:form:fields.html.twig``.
339338

340339
Child Forms
341340
...........
@@ -344,16 +343,16 @@ You can also apply a form theme to a specific child of your form:
344343

345344
.. code-block:: html+twig
346345

347-
{% form_theme form.child 'AppBundle:Form:fields.html.twig' %}
346+
{% form_theme form.child 'form/fields.html.twig' %}
348347

349348
This is useful when you want to have a custom theme for a nested form that's
350349
different than the one of your main form. Just specify both your themes:
351350

352351
.. code-block:: html+twig
353352

354-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
353+
{% form_theme form 'form/fields.html.twig' %}
355354

356-
{% form_theme form.child 'AppBundle:Form:fields_child.html.twig' %}
355+
{% form_theme form.child 'form/fields_child.html.twig' %}
357356

358357
.. _cookbook-form-php-theming:
359358

@@ -369,9 +368,13 @@ file in order to customize the ``integer_widget`` fragment.
369368

370369
.. code-block:: html+php
371370

372-
<!-- app/Resources/views/Form/integer_widget.html.php -->
371+
<!-- app/Resources/views/form/integer_widget.html.php -->
373372
<div class="integer_widget">
374-
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "number")) ?>
373+
<?php echo $view['form']->block(
374+
$form,
375+
'form_widget_simple',
376+
array('type' => isset($type) ? $type : "number")
377+
) ?>
375378
</div>
376379

377380
Now that you've created the customized form template, you need to tell Symfony
@@ -382,7 +385,7 @@ tell Symfony to use the theme via the ``setTheme`` helper method:
382385

383386
.. code-block:: php
384387
385-
<?php $view['form']->setTheme($form, array('AppBundle:Form')); ?>
388+
<?php $view['form']->setTheme($form, array(':form')); ?>
386389
387390
<?php $view['form']->widget($form['age']) ?>
388391
@@ -395,7 +398,14 @@ method:
395398

396399
.. code-block:: php
397400
398-
<?php $view['form']->setTheme($form['child'], 'AppBundle:Form/Child'); ?>
401+
<?php $view['form']->setTheme($form['child'], ':form'); ?>
402+
403+
.. note::
404+
405+
The ``:form`` syntax is based on the functional names for templates:
406+
``Bundle:Directory``. As the form directory lives in the
407+
``app/Resources/views`` directory, the ``Bundle`` part is empty, resulting
408+
in ``:form``.
399409

400410
.. _cookbook-form-twig-import-base-blocks:
401411

@@ -469,8 +479,8 @@ Twig
469479
~~~~
470480

471481
By using the following configuration, any customized form blocks inside the
472-
``AppBundle:Form:fields.html.twig`` template will be used globally when a
473-
form is rendered.
482+
``form/fields.html.twig`` template will be used globally when a form is
483+
rendered.
474484

475485
.. configuration-block::
476486

@@ -479,14 +489,14 @@ form is rendered.
479489
# app/config/config.yml
480490
twig:
481491
form_themes:
482-
- 'AppBundle:Form:fields.html.twig'
492+
- 'form/fields.html.twig'
483493
# ...
484494

485495
.. code-block:: xml
486496
487497
<!-- app/config/config.xml -->
488498
<twig:config>
489-
<twig:form-theme>AppBundle:Form:fields.html.twig</twig:form-theme>
499+
<twig:form-theme>form/fields.html.twig</twig:form-theme>
490500
<!-- ... -->
491501
</twig:config>
492502
@@ -495,7 +505,7 @@ form is rendered.
495505
// app/config/config.php
496506
$container->loadFromExtension('twig', array(
497507
'form_themes' => array(
498-
'AppBundle:Form:fields.html.twig',
508+
'form/fields.html.twig',
499509
),
500510

501511
// ...
@@ -671,7 +681,7 @@ customize the ``name`` field only:
671681
.. code-block:: html+php
672682

673683
<!-- Main template -->
674-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
684+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
675685

676686
<?php echo $view['form']->widget($form['name']); ?>
677687

@@ -728,7 +738,7 @@ You can also override the markup for an entire field row using the same method:
728738
.. code-block:: html+php
729739

730740
<!-- Main template -->
731-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
741+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
732742

733743
<?php echo $view['form']->row($form['name']); ?>
734744

cookbook/security/_ircmaxwell_password-compat.rst.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
.. code-block:: bash
77

8-
$ require ircmaxell/password-compat "~1.0"
8+
$ composer require ircmaxell/password-compat "~1.0"

create_framework/dependency-injection.rst renamed to create_framework/dependency_injection.rst

-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ empty class, you might be tempted to move some code from the front controller
77
to it::
88

99
// example.com/src/Simplex/Framework.php
10-
1110
namespace Simplex;
1211

1312
use Symfony\Component\Routing;
@@ -33,7 +32,6 @@ to it::
3332
The front controller code would become more concise::
3433

3534
// example.com/web/front.php
36-
3735
require_once __DIR__.'/../vendor/autoload.php';
3836

3937
use Symfony\Component\HttpFoundation\Request;
@@ -94,7 +92,6 @@ container:
9492
Create a new file to host the dependency injection container configuration::
9593

9694
// example.com/src/container.php
97-
9895
use Symfony\Component\DependencyInjection;
9996
use Symfony\Component\DependencyInjection\Reference;
10097

@@ -147,7 +144,6 @@ it in other object definitions.
147144
The front controller is now only about wiring everything together::
148145

149146
// example.com/web/front.php
150-
151147
require_once __DIR__.'/../vendor/autoload.php';
152148

153149
use Symfony\Component\HttpFoundation\Request;
@@ -165,7 +161,6 @@ As all the objects are now created in the dependency injection container, the
165161
framework code should be the previous simple version::
166162

167163
// example.com/src/Simplex/Framework.php
168-
169164
namespace Simplex;
170165

171166
use Symfony\Component\HttpKernel\HttpKernel;

0 commit comments

Comments
 (0)