IN the AcmePizza BUndle this is working fine
->add(\'pizza\', \'entity\', array(
\'class\' => \'Acme\\PizzaBundle\\Entity\\Pizza\',
Assuming Your userTasks is an relationship You will find answer for Your case here. These is just how to sort but if You had required some WHERE conditions it is not so simple but neither it is hard.
I had to filter out some entities, the key to solve it was to create set/get method in entity class returning required set.
In my case it looks like this
/**
* Set values
*
* @param ArrayCollection $values
* @return Attribute
*/
public function setCustomValues($values)
{
$result = $this->getNotCustomValues();
foreach ($values as $value)
{
$value->setAttribute($this);
$result->add($value);
}
$this->values = $result;
return $this;
}
/**
* Get values
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCustomValues()
{
$result = new ArrayCollection();
foreach ($this->values as $value) {
if($value->getCustom()) {
$result->add($value);
}
}
return $result;
}
And when creating form, name for a field is "customvalues" instead of "values" So my collection contains only values with custom field true.