Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Extending Symfony2 Web Application Framework

You're reading from   Extending Symfony2 Web Application Framework Symfony2 took the great features of the original framework to new levels of extensibility. With this practical guide you'll learn how to make the most of Symfony2 through controlling your code and sharing it more widely.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783287192
Length 140 pages
Edition Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sebastien Armand Sebastien Armand
Author Profile Icon Sebastien Armand
Sebastien Armand
Arrow right icon
View More author details
Toc

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 be an empty coordinate:

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults([
        'widget' => 'coordinate',
        'compound' => false,
        'data_class' => ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image