Doctrine not saving ManyToMany

Say you have a ManyToMany relationship, like Post <—> Tag.

When you add tags to a Post and the save the Post, everything is great. But when you add posts to a Tag and then save the Tag, the posts are not saved. Why? Because Doctrine persists changes only on the owning side of a relation. The owning side is…

Read More

Symfony Form: Extract Values

I had to look deep into Symfony 1.4 code this morning as I was trying to get a field’s value. Form values come from different sources: default values, record values (when editing, for example), original POST values and clean POST values. So when is each available and how do we get it?…

Read More

Symfony task “default” context

When creating Symfony 1.4 CLI tasks, I stumbled upon an error message: The “default” context does not exist. After searching some old forums, I found a solution. Before you access any Doctrine class, you mus first bootstrap your context correctly. Here is an example:

The application name and the environment can come from CLI…

Read More

Integrating Markdown with Symfony

I needed to create a help section in three languages in a Symfony 1.4 application. I wanted to make the technical writer’s life as easy as possible and the source files easy to read for everyone. Markdown seemed like a good solution. Because Symfony can cache static pages, Markdown will only parse each page once. I did not have to worry about performance! Here is how to quickly add Markdown to your Symfony 1.4 application.


Read More

Symfony – subfolders for partials

Symfony 1.2 – 1.4 expects all partials to follow this convention: templates/_partial.php What happens when you need to organize your partials in subfolder? I tried a number of “Symfunky” avenues. Feel free to skip to the solution. Avenues Explored I first try the call the include_partial helper with “subfolder/partial”, but that results in Symfony attempting…

Read More