public function getRelationForm($relationName, $options = array())
{
$options = array_merge(array('hide_on_new' => false, 'collection_form_class' => 'sfFormPropelCollection', 'criteria' => null, 'add_delete' => true), $options);
if ($this->getObject()->isNew() && $options['hide_on_new']) {
return;
}
unset($options['hide_on_new']);
// compute relation elements
$relationMap = $this->getRelationMap($relationName);
if ($relationMap->getType() != RelationMap::ONE_TO_MANY) {
throw new sfException('embedRelation() only works for one-to-many relationships');
}
$collection = call_user_func_array(array($this->getObject(), sprintf('get%s', $relationMap->getPluralName())), array($options['criteria']));
unset($options['criteria']);
// compute relation fields, to be removed from embedded forms
// because this data is not editable
if (!isset($options['remove_fields'])) {
$options['remove_fields'] = $this->getRelationFields($relationMap);
}
// create the relation form
$collectionFormClass = $options['collection_form_class'];
unset($options['collection_form_class']);
$collectionForm = new $collectionFormClass($collection, $options);
return $collectionForm;
}