Symfony2 Setting a default choice field selection

You can define the default value from the ‘data’ attribute. This is part of the Abstract “field” type (http://symfony.com/doc/2.0/reference/forms/types/field.html) $form = $this->createFormBuilder() ->add(‘status’, ‘choice’, array( ‘choices’ => array( 0 => ‘Published’, 1 => ‘Draft’ ), ‘data’ => 1 )) ->getForm(); In this example, ‘Draft’ would be set as the default selected value.

Difference between ObjectManager and EntityManager in Symfony2?

ObjectManager is an interface and EntityManager is its ORM implementation. It’s not the only implementation; for example, DocumentManager from MongoDB ODM implements it as well. ObjectManager provides only the common subset of all its implementations. If you want your form type to work with any ObjectManager implementation, then use it. This way you could switch … Read more