Form by_reference = true

if you are extending an entity, most of the time, you can ignore the by_reference field option. This is because it is set to true by default and its usually what you want.

for example

$formMapper->add('owner', 'entity', array(
                'class' => 'YourBundle:User',
                'multiple' => false,
                'required' => true,
                'label' => 'Gallery Owner'

This form field uses the variable “owner” as defined in the user class. it will call setOwner in the user class when the form is submitted before saving into the db.

Setting by_reference to false forces the framework to call the setter on the parent object instead. Since you are extending the parent entity, most of the time, you don’t want to touch the parent entity.

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.