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

Data transformers


By using data transformers, the form components in Symfony offer a powerful way of dealing with this scenario. The form component allows three distinct representations of the same data, which are as follows:

  • The one in the view (in the HTML)

  • The one in the model

  • The one in the form itself (if necessary)

In most cases, this is overkill. For our current case, only one transformer will be enough to go from a string (such as 42.0321650 and 115.032160513) to the PHP object representation. However, if you think about date and time, it can be that your form offers the choice that the view shows three select boxes for the year, month, and day; a datepicker; or a timestamp-based value. At the same time, you can expect that your PHP model object always needs it as a string based on a certain format. If you want to create a form type that offers this kind of flexibility, it's better if the form internally keeps everything as a DateTime object, and then transforms it for the view or the...

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