Skip to content

Commit b362d67

Browse files
blue-eyesfabpot
authored andcommitted
[forms-validator] Updated code
1 parent b185a9a commit b362d67

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

guides/forms.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Now let's create a form to let the visitor fill the data of the object::
4444
{
4545
$customer = new Customer();
4646

47-
$form = new Form('customer', $customer, $this->container->getValidatorService());
47+
$form = new Form('customer', $customer, $this['validator']);
4848
$form->add(new TextField('name'));
4949
$form->add(new IntegerField('age'));
5050

@@ -74,7 +74,7 @@ the data is stored in a POST parameter with the name of the form::
7474
public function signupAction()
7575
{
7676
$customer = new Customer();
77-
$form = new Form('customer', $customer, $this->container->getValidatorService());
77+
$form = new Form('customer', $customer, $this['validator']);
7878

7979
// form setup...
8080

@@ -267,7 +267,7 @@ Now we can easily adapt the form in the controller::
267267
$registration = new Registration();
268268
$registration->customer = new Customer();
269269

270-
$form = new Form('registration', $registration, $this->container->getValidatorService());
270+
$form = new Form('registration', $registration, $this['validator']);
271271
$form->add(new CheckboxField('termsAccepted'));
272272

273273
$group = new FieldGroup('customer');

guides/validator.rst

+3-5
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ by default. You can enable it in your ``config.yml``:
5353
5454
Now let's try to validate an object::
5555

56-
$validator = $this->container->getValidatorService();
57-
5856
$author = new Author();
5957
$author->firstName = 'B.';
60-
61-
print $validator->validate($author);
62-
58+
59+
print $this['validator']->validate($author);
60+
6361
You should see the following output:
6462

6563
.. code-block:: yaml

0 commit comments

Comments
 (0)