Adding extra fields to FOSUserBundle / SonataUserBundle

Sadly, this isn’t really documented (at time of writing).

Adding new protected variables to your User.php entity will not actually create database entries when you try to do a doctrine:schema:update.

While one still needs to have the protected variables in this entity class, along with getters and setters, the actual creation work is within UserBundle/Resources/config/doctrine/User.orm.xml

Here is an example for adding a foreign key:

Symfony 1.4 Doctrine 1.2 MS SQL Server

Web server: Linux (Ubuntu on my dev setup), Apache, PHP 5.3, Symfony 1.4, Doctrine 1.2.
Database server: Microsoft Windows 2008 Server, MS SQL Server

Trying to get Symfony to talk to the database server has been a painful experience for the last few days. But perseverance has paid off.

Lots of Googling with trial & error has resulted in actually achieving a development setup that will mirror the eventual production setup.

Short version:

  1. Follow the FreeTDS and ODBC setup instructions of
  2. Use the following in config/databases.yml

In the above snippit, replace ‘datasourcename’ with whatever you used in /etc/odbc.ini and replace ‘sqlserver’ with the name used in /etc/freetds/freetds.conf & /etc/odbc.ini

It’s late and I’ve been struggling to get this working for some time. I may expand this entry in the future if required.

References and insperation:


How to get sfFormExtraPlugin working in Symfony 1.4 using Doctrine

I’m talking about this plugin:

For some reason, getting the plugin to work took a lot of Googling and some trial and error.
So here is how I got it working. Hopefully I did this in the ‘correct’ way…

Edit config/ProjectConfiguration.class.php to add sfFormExtraPlugin as an enabled plugin:

Edit apps/<app_name>/config/view.yml to include the JS and CSS:

Edit lib/form/doctrine/<your_module_name>Form.class.php to make use of the widgets you want. I’m interested in sfWidgetFormJQueryDate:

I have used the calendar.png icon from the famfamfam silk icon set. You can get the set here:

I’ve used the date picker widget for filling in the created_at and updated_at fields. You can replace these values with the fields you need to manipulate in a user friendly way.

[Edit 17/10/2010:]
I’m not going mad, there is an issue with the ‘magic’ fields created_at and updated_at in that they have to be unset to become magic.
Found help here:
Though the unset lines are better off being added just once to /lib/form/doctrine/BaseFormDoctrine.class.php, rather than each xxxForm.class.php file.