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

Going further


For the last part of this chapter, we will go a bit further with the customization of forms.

A part of our meetups website requires a user to enter their house address so that they can receive a membership card that will be directly sent out to them. Since we already have a relatively good idea where that user is coming from, we will preset the country for them in the form. Here, we only differentiate between users coming from within or outside the USA to decide if they must fill in the state they are coming from.

The initial setup

Our Address class is very simple and contains only a few attributes as well as getters and setters, as shown in the following code snippet:

class Address
{
    protected $id;

    protected $street;

    protected $number;

    protected $country;

    protected $state;

    protected $zip;

    // public function getXxx();
    // public function setXxx($x);
}

The basic form class will be as shown in the following code:

class AddressType extends AbstractType...
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