public function configure()
{
// fusionamos el formulario de contactos
$this->mergeForm(new ContactoForm(ContactoPeer::retrieveByPK($this->getObject()->getId())));
}
/**
* Actualizamos los formularios agregado
* en caso de tener varios mergeForm
* @param string $subform Nombre de la clase form, ejem. ContactoForm = Contacto
*/
protected function updateSubform($subform)
{
if(!is_null($objectSubform = $this->getObjectSubform($subform)))
{
$values = $this->getValues();
if($objectSubform->isNew())
{
$values['id'] = $this->object->getId();
}
$objectSubform->fromArray($values,BasePeer::TYPE_FIELDNAME);
$objectSubform->save();
}
}
/**
* Retorna el objeto FichaAsociado, si no existe crea uno
* @return objeto propel
*/
protected function getObjectSubform($subform)
{
$getSubform = 'get'.$subform;
if(!$this->object->$getSubform())
{
return new $subform();
}
return $this->object->$getSubform();
}
/**
* Reescribimos el método save
*/
public function save($con = null)
{
parent::save();
$this->updateSubform('Contacto');
return $this->object;
}