entity framework - Symfony2 Filter Collections in Form -


we have user entity has relations(onetomany) other entities. while building formtype user entity. have took associated entities collection.

         $builder->add('sso_users_organization', "collection", array('type'=>new usersorganizationtype(),'allow_add' => true) ); 

we want show associated entities filtering based on status "active".

we have tried filtering in below way.

$organizations = $userentity->getssousersorganization(); foreach($organizations $key=>$org){     if($org->getstatus() == 0){        unset($organizations[$key]);     } } 

but when saving details back, other records having status "inactive" getting deleted.

please can me out.

thanks

try this. $er entity repository of type specified "class". in case usersorganizationtyperepository

$builder->add('sso_users_organization', "entity", array(     "class" => "acme\appbundle\usersorganizationtype",     "query_builder" => function(entityrepository $er){          return $er->createquerybuilder('uot')              ->where('uot.active = true');      }  ); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -