Skip to content

Commit 1cfd349

Browse files
committed
Fixed code examples in book/validation
1 parent 59c1e41 commit 1cfd349

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

book/validation.rst

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ following:
5656
.. code-block:: php-annotations
5757
5858
// src/Acme/BlogBundle/Entity/Author.php
59+
60+
// ...
5961
use Symfony\Component\Validator\Constraints as Assert;
6062
6163
class Author
@@ -85,6 +87,7 @@ following:
8587
8688
// src/Acme/BlogBundle/Entity/Author.php
8789
90+
// ...
8891
use Symfony\Component\Validator\Mapping\ClassMetadata;
8992
use Symfony\Component\Validator\Constraints\NotBlank;
9093
@@ -118,9 +121,9 @@ simple example from inside a controller:
118121

119122
.. code-block:: php
120123
124+
// ...
121125
use Symfony\Component\HttpFoundation\Response;
122126
use Acme\BlogBundle\Entity\Author;
123-
// ...
124127
125128
public function indexAction()
126129
{
@@ -174,7 +177,6 @@ Inside the template, you can output the list of errors exactly as needed:
174177
.. code-block:: html+jinja
175178

176179
{# src/Acme/BlogBundle/Resources/views/Author/validate.html.twig #}
177-
178180
<h3>The author has the following errors</h3>
179181
<ul>
180182
{% for error in errors %}
@@ -185,7 +187,6 @@ Inside the template, you can output the list of errors exactly as needed:
185187
.. code-block:: html+php
186188

187189
<!-- src/Acme/BlogBundle/Resources/views/Author/validate.html.php -->
188-
189190
<h3>The author has the following errors</h3>
190191
<ul>
191192
<?php foreach ($errors as $error): ?>
@@ -214,10 +215,10 @@ and bound. The constraint violations on the object are converted into ``FieldErr
214215
objects that can easily be displayed with your form. The typical form submission
215216
workflow looks like the following from inside a controller::
216217

218+
// ...
217219
use Acme\BlogBundle\Entity\Author;
218220
use Acme\BlogBundle\Form\AuthorType;
219221
use Symfony\Component\HttpFoundation\Request;
220-
// ...
221222

222223
public function updateAction(Request $request)
223224
{
@@ -230,7 +231,7 @@ workflow looks like the following from inside a controller::
230231
if ($form->isValid()) {
231232
// the validation passed, do something with the $author object
232233

233-
return $this->redirect($this->generateUrl('...'));
234+
return $this->redirect($this->generateUrl(...));
234235
}
235236
}
236237

@@ -370,6 +371,8 @@ constraint, have several configuration options available. Suppose that the
370371
.. code-block:: php
371372
372373
// src/Acme/BlogBundle/Entity/Author.php
374+
375+
// ...
373376
use Symfony\Component\Validator\Mapping\ClassMetadata;
374377
use Symfony\Component\Validator\Constraints\NotBlank;
375378
@@ -406,6 +409,8 @@ options can be specified in this way.
406409
.. code-block:: php-annotations
407410
408411
// src/Acme/BlogBundle/Entity/Author.php
412+
413+
// ...
409414
use Symfony\Component\Validator\Constraints as Assert;
410415
411416
class Author
@@ -437,6 +442,8 @@ options can be specified in this way.
437442
.. code-block:: php
438443
439444
// src/Acme/BlogBundle/Entity/Author.php
445+
446+
// ...
440447
use Symfony\Component\Validator\Mapping\ClassMetadata;
441448
use Symfony\Component\Validator\Constraints\Choice;
442449
@@ -502,6 +509,8 @@ class to have at least 3 characters.
502509
.. code-block:: php-annotations
503510
504511
// Acme/BlogBundle/Entity/Author.php
512+
513+
// ...
505514
use Symfony\Component\Validator\Constraints as Assert;
506515
507516
class Author
@@ -526,6 +535,8 @@ class to have at least 3 characters.
526535
.. code-block:: php
527536
528537
// src/Acme/BlogBundle/Entity/Author.php
538+
539+
// ...
529540
use Symfony\Component\Validator\Mapping\ClassMetadata;
530541
use Symfony\Component\Validator\Constraints\NotBlank;
531542
use Symfony\Component\Validator\Constraints\MinLength;
@@ -571,6 +582,8 @@ this method must return ``true``:
571582
.. code-block:: php-annotations
572583
573584
// src/Acme/BlogBundle/Entity/Author.php
585+
586+
// ...
574587
use Symfony\Component\Validator\Constraints as Assert;
575588
576589
class Author
@@ -598,6 +611,8 @@ this method must return ``true``:
598611
.. code-block:: php
599612
600613
// src/Acme/BlogBundle/Entity/Author.php
614+
615+
// ...
601616
use Symfony\Component\Validator\Mapping\ClassMetadata;
602617
use Symfony\Component\Validator\Constraints\True;
603618
@@ -799,7 +814,7 @@ it looks like this::
799814
// this is *not* a valid email address
800815
$errorMessage = $errorList[0]->getMessage()
801816
802-
// do something with the error
817+
// ... do something with the error
803818
}
804819
805820
// ...

0 commit comments

Comments
 (0)