I have a problem when I have to insert Entity data in the database.
The entities are showed with the entity field of Symfony2 and I'm using the Query Builder to show only data that is "active". (see below)
Data can be added to the "select" generated by Symfony via Ajax (new "profs" that aren't active (is_active = 0)). But when I select data, added via Ajax and that's not active, I have this error: "This value is not valid." => that's because Symfony2 adds automatic validation due to de querybuilder "where" statement.
Is it possible to override the default Symfony2 behaviour, so that also not active (is_active = 0 (boolean)) -added elements via Ajax- elements can be validated (items that doesn't match the query builder "where" statement below?
$builder->add('professionA', 'genemu_jquerychosen_entity', array(
'class' => 'SportUserBundle:Profession',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('prof')
->where('prof.is_active = :active')
->setParameters(array('active' => '1'))
->orderBy('prof.name', 'ASC');
},
));
Thanks!