Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e4b42d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 9df347b + 7ed12af commit 9e4b42d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2079
-836
lines changed

book/doctrine.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,12 +1375,12 @@ For more information about Doctrine, see the *Doctrine* section of the
13751375

13761376
.. _`Doctrine`: http://www.doctrine-project.org/
13771377
.. _`MongoDB`: http://www.mongodb.org/
1378-
.. _`Basic Mapping Documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html
1379-
.. _`Query Builder`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/query-builder.html
1380-
.. _`Doctrine Query Language`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html
1381-
.. _`Association Mapping Documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html
1378+
.. _`Basic Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/basic-mapping.html
1379+
.. _`Query Builder`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/query-builder.html
1380+
.. _`Doctrine Query Language`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/dql-doctrine-query-language.html
1381+
.. _`Association Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/association-mapping.html
13821382
.. _`DateTime`: http://php.net/manual/en/class.datetime.php
1383-
.. _`Mapping Types Documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#doctrine-mapping-types
1384-
.. _`Property Mapping documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#property-mapping
1385-
.. _`Lifecycle Events documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/events.html#lifecycle-events
1386-
.. _`Reserved SQL keywords documentation`: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#quoting-reserved-words
1383+
.. _`Mapping Types Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/basic-mapping.html#doctrine-mapping-types
1384+
.. _`Property Mapping documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/basic-mapping.html#property-mapping
1385+
.. _`Lifecycle Events documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/events.html#lifecycle-events
1386+
.. _`Reserved SQL keywords documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/basic-mapping.html#quoting-reserved-words

book/forms.rst

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ corresponding errors printed out with the form.
356356
a ``required`` attribute on fields that are required. For browsers that
357357
support HTML5, this will result in a native browser message being displayed
358358
if the user tries to submit the form with that field blank.
359-
359+
360360
Generated forms take full advantage of this new feature by adding sensible
361361
HTML attributes that trigger the validation. The client-side validation,
362362
however, can be disabled by adding the ``novalidate`` attribute to the
@@ -484,13 +484,13 @@ the documentation for each type.
484484
that HTML5-ready browsers will apply client-side validation if the field
485485
is left blank. If you don't want this behavior, either set the ``required``
486486
option on your field to ``false`` or :ref:`disable HTML5 validation<book-forms-html5-validation-disable>`.
487-
487+
488488
Also note that setting the ``required`` option to ``true`` will **not**
489489
result in server-side validation to be applied. In other words, if a
490490
user submits a blank value for the field (either with an old browser
491491
or web service, for example), it will be accepted as a valid value unless
492492
you use Symfony's ``NotBlank`` or ``NotNull`` validation constraint.
493-
493+
494494
In other words, the ``required`` option is "nice", but true server-side
495495
validation should *always* be used.
496496

@@ -569,7 +569,7 @@ the correct values of a number of field options.
569569
option can be guessed from the validation constrains (if ``MinLength``
570570
or ``Min`` is used) or from the Doctrine metadata (via the field's length).
571571

572-
* ``max_length``: Similar to ``min_length``, the maximum length can also
572+
* ``max_length``: Similar to ``min_length``, the maximum length can also
573573
be guessed.
574574

575575
.. note::
@@ -651,11 +651,11 @@ output can be customized on many different levels.
651651
.. tip::
652652

653653
You can access the current data of your form via ``form.vars.value``:
654-
654+
655655
.. configuration-block::
656656

657657
.. code-block:: jinja
658-
658+
659659
{{ form.vars.value.task }}
660660
661661
.. code-block:: html+php
@@ -725,7 +725,7 @@ specify it:
725725

726726
<?php echo $view['form']->label($form['task'], 'Task Description') ?>
727727

728-
Finally, some field types have additional rendering options that can be passed
728+
Some field types have additional rendering options that can be passed
729729
to the widget. These options are documented with each type, but one common
730730
options is ``attr``, which allows you to modify attributes on the form element.
731731
The following would add the ``task_field`` class to the rendered input text
@@ -743,6 +743,33 @@ field:
743743
'attr' => array('class' => 'task_field'),
744744
)) ?>
745745

746+
If you need to render form fields "by hand" then you can access individual
747+
values for fields such as the ``id``, ``name`` and ``label``. For example
748+
to get the ``id``:
749+
750+
.. configuration-block::
751+
752+
.. code-block:: html+jinja
753+
754+
{{ form.task.vars.id }}
755+
756+
.. code-block:: html+php
757+
758+
<?php echo $form['task']->get('id') ?>
759+
760+
To get the value used for the form field's name attribute you need to use
761+
the ``full_name`` value:
762+
763+
.. configuration-block::
764+
765+
.. code-block:: html+jinja
766+
767+
{{ form.task.vars.full_name }}
768+
769+
.. code-block:: html+php
770+
771+
<?php echo $form['task']->get('full_name') ?>
772+
746773
Twig Template Function Reference
747774
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
748775

@@ -829,6 +856,25 @@ the choice is ultimately up to you.
829856
);
830857
}
831858

859+
.. tip::
860+
861+
When mapping forms to objects, all fields are mapped. Any fields on the
862+
form that do not exist on the mapped object will cause an exception to
863+
be thrown.
864+
865+
In cases where you need extra fields in the form (for example: a "do you
866+
agree with these terms" checkbox) that will not be mapped to the underlying
867+
object, you need to set the property_path option to ``false``::
868+
869+
public function buildForm(FormBuilder $builder, array $options)
870+
{
871+
$builder->add('task');
872+
$builder->add('dueDate', null, array('property_path' => false));
873+
}
874+
875+
Additionally, if there are any fields on the form that aren't included in
876+
the submitted data, those fields will be explicitly set to ``null``.
877+
832878
.. index::
833879
pair: Forms; Doctrine
834880

@@ -1076,6 +1122,8 @@ renders the form:
10761122

10771123
{% form_theme form 'AcmeTaskBundle:Form:fields.html.twig' %}
10781124

1125+
{% form_theme form 'AcmeTaskBundle:Form:fields.html.twig' 'AcmeTaskBundle:Form:fields2.html.twig' %}
1126+
10791127
<form ...>
10801128

10811129
.. code-block:: html+php
@@ -1084,6 +1132,8 @@ renders the form:
10841132

10851133
<?php $view['form']->setTheme($form, array('AcmeTaskBundle:Form')) ?>
10861134

1135+
<?php $view['form']->setTheme($form, array('AcmeTaskBundle:Form', 'AcmeTaskBundle:Form')) ?>
1136+
10871137
<form ...>
10881138

10891139
The ``form_theme`` tag (in Twig) "imports" the fragments defined in the given
@@ -1092,6 +1142,13 @@ template and uses them when rendering the form. In other words, when the
10921142
block from your custom theme (instead of the default ``field_row`` block
10931143
that ships with Symfony).
10941144

1145+
Your custom theme does not have to override all the blocks. When rendering a block
1146+
which is not overridden in your custom theme, the theming engine will fall back
1147+
to the global theme (defined at the bundle level).
1148+
1149+
If several custom themes are provided they will be searched in the listed order
1150+
before falling back to the global theme.
1151+
10951152
To customize any portion of a form, you just need to override the appropriate
10961153
fragment. Knowing exactly which block or file to override is the subject of
10971154
the next section.
@@ -1339,7 +1396,7 @@ The CSRF token can be customized on a form-by-form basis. For example::
13391396
class TaskType extends AbstractType
13401397
{
13411398
// ...
1342-
1399+
13431400
public function getDefaultOptions(array $options)
13441401
{
13451402
return array(
@@ -1350,7 +1407,7 @@ The CSRF token can be customized on a form-by-form basis. For example::
13501407
'intention' => 'task_item',
13511408
);
13521409
}
1353-
1410+
13541411
// ...
13551412
}
13561413

@@ -1389,14 +1446,14 @@ an array of the submitted data. This is actually really easy::
13891446
->add('email', 'email')
13901447
->add('message', 'textarea')
13911448
->getForm();
1392-
1449+
13931450
if ($request->getMethod() == 'POST') {
13941451
$form->bindRequest($request);
13951452

13961453
// data is an array with "name", "email", and "message" keys
13971454
$data = $form->getData();
13981455
}
1399-
1456+
14001457
// ... render the form
14011458
}
14021459

@@ -1416,14 +1473,14 @@ an array.
14161473

14171474
.. tip::
14181475

1419-
You can also access POST values (in this case "name") directly through
1476+
You can also access POST values (in this case "name") directly through
14201477
the request object, like so:
14211478

14221479
.. code-block:: php
14231480
14241481
$this->get('request')->request->get('name');
14251482
1426-
Be advised, however, that in most cases using the getData() method is
1483+
Be advised, however, that in most cases using the getData() method is
14271484
a better choice, since it returns the data (usually an object) after
14281485
it's been transformed by the form framework.
14291486

@@ -1456,7 +1513,7 @@ but here's a short example::
14561513
// ...
14571514
;
14581515

1459-
Now, when you call `$form->isValid()`, the constraints setup here are run
1516+
Now, when you call `$form->bindRequest($request)`, the constraints setup here are run
14601517
against your form's data. If you're using a form class, override the ``getDefaultOptions``
14611518
method to specify the option::
14621519

@@ -1478,15 +1535,15 @@ method to specify the option::
14781535
'name' => new MinLength(5),
14791536
'email' => new Email(array('message' => 'Invalid email address')),
14801537
));
1481-
1538+
14821539
return array('validation_constraint' => $collectionConstraint);
14831540
}
14841541
}
14851542

14861543
Now, you have the flexibility to create forms - with validation - that return
14871544
an array of data, instead of an object. In most cases, it's better - and
14881545
certainly more robust - to bind your form to an object. But for simple forms,
1489-
this is a great approach.
1546+
this is a great approach.
14901547

14911548
Final Thoughts
14921549
--------------

book/http_cache.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ finely tuned via a set of options you can set by overriding the ``getOptions()``
173173
method::
174174

175175
// app/AppCache.php
176-
class AppCache extends Cache
176+
177+
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
178+
179+
class AppCache extends HttpCache
177180
{
178181
protected function getOptions()
179182
{
@@ -654,7 +657,7 @@ exposing a simple and efficient pattern::
654657
} else {
655658
// do more work here - like retrieving more data
656659
$comments = // ...
657-
660+
658661
// or render a template with the $response you've already started
659662
return $this->render(
660663
'MyBundle:MyController:article.html.twig',

book/http_fundamentals.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ the user is connecting via a secured connection (i.e. ``https``).
263263
In fact, every public property used in the previous example is some instance
264264
of the ParameterBag.
265265

266+
.. _book-fundamentals-attributes:
267+
266268
The Request class also has a public ``attributes`` property, which holds
267269
special data related to how the application works internally. For the
268270
Symfony2 framework, the ``attributes`` holds the values returned by the
@@ -490,7 +492,7 @@ regardless of how your project is developed. To name a few:
490492
should be handled (e.g. execute the ``contactAction()`` method);
491493

492494
* `Form`_ - A full-featured and flexible framework for creating forms and
493-
handing form submissions;
495+
handling form submissions;
494496

495497
* `Validator`_ A system for creating rules about data and then validating
496498
whether or not user-submitted data follows those rules;

book/installation.rst

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,40 @@ something like this:
7171
app.php
7272
...
7373
74+
.. _installation-updating-vendors:
75+
7476
Updating Vendors
7577
~~~~~~~~~~~~~~~~
7678

77-
Finally, if you downloaded the archive "without vendors", install the vendors
78-
by running the following command from the command line:
79+
Step 1: Get `Composer`_ (The great new PHP packaging system)
80+
81+
.. code-block:: bash
82+
83+
curl -s http://getcomposer.org/installer | php
84+
85+
Make sure you download ``composer.phar`` in the same folder where
86+
the ``composer.json`` file is located (this is your Symfony project
87+
root by default).
88+
89+
Step 2: Install vendors
7990

8091
.. code-block:: bash
8192
82-
php bin/vendors install
93+
php composer.phar install
8394
8495
This command downloads all of the necessary vendor libraries - including
85-
Symfony itself - into the ``vendor/`` directory. For more information on
86-
how third-party vendor libraries are managed inside Symfony2, see
87-
":ref:`cookbook-managing-vendor-libraries`".
96+
Symfony itself - into the ``vendor/`` directory.
97+
98+
.. note::
99+
100+
If you don't have ``curl`` installed, you can also just download the ``installer``
101+
file manually at http://getcomposer.org/installer. Place this file into your
102+
project and then run:
103+
104+
.. code-block:: bash
105+
106+
php installer
107+
php composer.phar install
88108
89109
Configuration and Setup
90110
~~~~~~~~~~~~~~~~~~~~~~~
@@ -206,10 +226,11 @@ file:
206226
207227
Now, the vendor directory won't be committed to source control. This is fine
208228
(actually, it's great!) because when someone else clones or checks out the
209-
project, he/she can simply run the ``php bin/vendors install`` script to
229+
project, he/she can simply run the ``php composer.phar install`` script to
210230
download all the necessary vendor libraries.
211231

212232
.. _`enable ACL support`: https://help.ubuntu.com/community/FilePermissions#ACLs
213233
.. _`http://symfony.com/download`: http://symfony.com/download
214234
.. _`Git`: http://git-scm.com/
215235
.. _`GitHub Bootcamp`: http://help.github.com/set-up-git-redirect
236+
.. _`Composer`: http://getcomposer.org/

0 commit comments

Comments
 (0)