I am using Form Classes to build the various form in my project.
In the Entity Type file, for the buildForm function, there is a secondary parameter of \"array $options\
I think you're not setting them properly in the first place. You're supposed to give them as third argument to createForm()
EDIT: Here is how your form class could look:
add('name')
->add('slug')
->add('reference')
->add('description')
->add('active_from')
->add('active_till')
->add('is_active')
->add('category', 'entity', array(
'class' => 'DEMO\DemoBundle\Entity\Product\ProductCategory',
'query_builder' => function(EntityRepository $er) use($options) {
return $er->createQueryBuilder('u')
->where('u.section = :id')
->setParameter('id', $options['id'])
->orderBy('u.root', 'ASC')
->addOrderBy('u.lft', 'ASC');
},
'empty_value' => 'Choose an option',
'property' => 'indentedName',
));
}
public function getDefaultOptions()
{
return array(
'data_class' => 'DEMO\DemoBundle\Entity\Product\Product',
'id' => null
);
}
public function getName()
{
return 'demo_demobundle_product_type';
}
}