In a previous post I showed the basics of how to create a symfony2 form data mapper but I never went into too much detail or gave examples. I know a lot of you are interested in this and so in this post, I will give you some more information about how and why.
The Use Case: We want to be able to quickly add various settings to a user
without the need of created a new column in our database. Our solution is to
have a table called
users and a table called
user_settings. The settings can
be used for things such as storing user preferences or account related settings
such as the number of cat pictures they can upload to your site.
These classes provide you with a solid use case for using a custom form data mapper. There are other ways to accomplish this problem, however it is of my opinion that this is one of the best ways to go about solving the use case.
If you find any issues or bugs with the above code, let me know.