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

Skip to content

Commit d4f9478

Browse files
committed
Merge branch '2.3'
2 parents 66f1672 + 08056fd commit d4f9478

File tree

9 files changed

+43
-33
lines changed

9 files changed

+43
-33
lines changed

book/forms.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,6 @@ Validation is a very powerful feature of Symfony2 and has its own
431431
Validation Groups
432432
~~~~~~~~~~~~~~~~~
433433

434-
.. tip::
435-
436-
If you're not using :ref:`validation groups <book-validation-validation-groups>`,
437-
then you can skip this section.
438-
439434
If your object takes advantage of :ref:`validation groups <book-validation-validation-groups>`,
440435
you'll need to specify which validation group(s) your form should use::
441436

@@ -1073,6 +1068,10 @@ the choice is ultimately up to you.
10731068
The field data can be accessed in a controller with::
10741069

10751070
$form->get('dueDate')->getData();
1071+
1072+
In addition, the data of an unmapped field can also be modified directly::
1073+
1074+
$form->get('dueDate')->setData(new \DateTime());
10761075

10771076
Defining your Forms as Services
10781077
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

components/config/definition.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ Or you may define a prototype for each node inside an array node::
174174
->children()
175175
->arrayNode('connections')
176176
->prototype('array')
177-
->children()
178-
->scalarNode('driver')->end()
179-
->scalarNode('host')->end()
180-
->scalarNode('username')->end()
181-
->scalarNode('password')->end()
177+
->children()
178+
->scalarNode('driver')->end()
179+
->scalarNode('host')->end()
180+
->scalarNode('username')->end()
181+
->scalarNode('password')->end()
182+
->end()
182183
->end()
183184
->end()
184185
->end()

components/options_resolver.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ The advantages of doing this will become more obvious as you continue::
5050
$this->options = $resolver->resolve($options);
5151
}
5252

53-
The ``$options`` property is an instance of
54-
:class:`Symfony\\Component\\OptionsResolver\\Options`, which implements
55-
:phpclass:`ArrayAccess`, :phpclass:`Iterator` and :phpclass:`Countable`. That
56-
means you can handle it just like a normal array::
53+
The options property now is a well defined array with all resolved options readily available::
5754

5855
// ...
5956
public function getHost()
@@ -76,8 +73,6 @@ Now, try to actually use the class::
7673
'password' => 'pa$$word',
7774
));
7875

79-
echo $mailer->getPassword();
80-
8176
Right now, you'll receive a
8277
:class:`Symfony\\Component\\OptionsResolver\\Exception\\InvalidOptionsException`,
8378
which tells you that the options ``host`` and ``password`` do not exist.

cookbook/bundles/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Before you can use composer to install a bundle, you should look for a
2121

2222
Packagist is the main archive for Composer. If you are searching
2323
for a bundle, the best thing you can do is check out
24-
`KnpBundles`_, it is the unofficial achive of Symfony Bundles. If
24+
`KnpBundles`_, it is the unofficial archive of Symfony Bundles. If
2525
a bundle contains a ``README`` file, it is displayed there and if it
2626
has a Packagist package it shows a link to the package. It's a
2727
really useful site to begin searching for bundles.

cookbook/form/dynamic_form_modification.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ The type would now look like::
485485
namespace Acme\DemoBundle\Form\Type;
486486
487487
// ...
488-
Acme\DemoBundle\Entity\Sport;
489-
Symfony\Component\Form\FormInterface;
488+
use Acme\DemoBundle\Entity\Sport;
489+
use Symfony\Component\Form\FormInterface;
490490
491491
class SportMeetupType extends AbstractType
492492
{
@@ -497,32 +497,28 @@ The type would now look like::
497497
;
498498
499499
$formModifier = function(FormInterface $form, Sport $sport) {
500-
$positions = $data->getSport()->getAvailablePositions();
500+
$positions = $sport->getAvailablePositions();
501501
502502
$form->add('position', 'entity', array('choices' => $positions));
503-
}
503+
};
504504
505505
$builder->addEventListener(
506506
FormEvents::PRE_SET_DATA,
507-
function(FormEvent $event) {
508-
$form = $event->getForm();
509-
507+
function(FormEvent $event) use ($formModifier) {
510508
// this would be your entity, i.e. SportMeetup
511509
$data = $event->getData();
512510
513-
$formModifier($event->getForm(), $sport);
511+
$formModifier($event->getForm(), $data->getSport());
514512
}
515513
);
516514
517515
$builder->get('sport')->addEventListener(
518516
FormEvents::POST_SUBMIT,
519517
function(FormEvent $event) use ($formModifier) {
520518
// It's important here to fetch $event->getForm()->getData(), as
521-
// $event->getData() will get you the client data (this is, the ID)
519+
// $event->getData() will get you the client data (that is, the ID)
522520
$sport = $event->getForm()->getData();
523521
524-
$positions = $sport->getAvailablePositions();
525-
526522
// since we've added the listener to the child, we'll have to pass on
527523
// the parent to the callback functions!
528524
$formModifier($event->getForm()->getParent(), $sport);

cookbook/routing/redirect_in_config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Your configuration will look like this:
2323
path: /
2424
defaults:
2525
_controller: FrameworkBundle:Redirect:urlRedirect
26-
route: /app
26+
path: /app
2727
permanent: true
2828
2929
In this example, you configure a route for the ``/`` path and let :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController`

cookbook/security/acl.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ cannot only be based on the person (``Token``) who is requesting access, but
99
also involve a domain object that access is being requested for. This is where
1010
the ACL system comes in.
1111

12+
.. sidebar:: Alternatives to ACLS
13+
14+
Using ACL's isn't trivial, and for simpler use cases, it may be overkill.
15+
If your permission logic could be described by just writing some code (e.g.
16+
to check if a Blog is owned by the current User), then consider using
17+
:doc:`voters </cookbook/security/voters>`. A voter is passed the object
18+
being voted on, which you can use to make complex decisions and effectively
19+
implement your own ACL. Enforcing authorization (e.g. the ``isGranted``
20+
part) will look similar to what you see in this entry, but your voter
21+
class will handle the logic behind the scenes, instead of the ACL system.
22+
1223
Imagine you are designing a blog system where your users can comment on your
1324
posts. Now, you want a user to be able to edit his own comments, but not those
1425
of other users; besides, you yourself want to be able to edit all comments. In

reference/forms/types/date.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,5 @@ These options inherit from the :doc:`field</reference/forms/types/form>` type:
151151
.. include:: /reference/forms/types/options/inherit_data.rst.inc
152152

153153
.. include:: /reference/forms/types/options/error_mapping.rst.inc
154+
155+
.. _`RFC 3339`: http://tools.ietf.org/html/rfc3339
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format
22
~~~~~~
33

4-
**type**: ``integer`` or ``string`` **default**: ``IntlDateFormatter::MEDIUM``
4+
**type**: ``integer`` or ``string`` **default**: `IntlDateFormatter::MEDIUM`_ (or ``yyyy-MM-dd`` if `widget`_ is ``single_text``)
55

66
Option passed to the ``IntlDateFormatter`` class, used to transform user input
77
into the proper format. This is critical when the `widget`_ option is
@@ -10,13 +10,19 @@ By default, the format is determined based on the current user locale: meaning
1010
that *the expected format will be different for different users*. You
1111
can override it by passing the format as a string.
1212

13-
For more information on valid formats, see `Date/Time Format Syntax`_. For
14-
example, to render a single text box that expects the user to enter ``yyyy-MM-dd``,
15-
use the following options::
13+
For more information on valid formats, see `Date/Time Format Syntax`_::
1614

1715
$builder->add('date_created', 'date', array(
1816
'widget' => 'single_text',
17+
// this is actually the default format for single_text
1918
'format' => 'yyyy-MM-dd',
2019
));
2120

21+
.. note::
22+
23+
If you want your field to be rendered as an HTML5 "date" field, you have
24+
use a ``single_text`` widget with the ``yyyy-MM-dd`` format (the `RFC 3339`_
25+
format) which is the default value if you use the ``single_text`` widget.
26+
2227
.. _`Date/Time Format Syntax`: http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax
28+
.. _`IntlDateFormatter::MEDIUM`: http://www.php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants

0 commit comments

Comments
 (0)
0