O'Reilly logo

Extending Symfony2 Web Application Framework by Sébastien Armand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Forms based on user data

We had previously defined our form type as a service, so now we will change its configuration for it to take the user_locator service as the second argument, as shown in the following code:

khepin.form.type.coordinate:
    class: Khepin\BookBundle\Form\CoordinateType
    scope: prototype
    arguments: [@ivory_google_map.map, @user_locator]
    tags:
        - { name: form.type, alias: coordinate }

If you recall correctly, the user_locator service was in the request scope, but our form type is in the prototype scope. Since the prototype scope is more restrictive than the request scope, we don't have any issues here.

We will also update the default values of CoordinateType using the following code so that it always has a default value, which will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required