Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.   public function configure()
  2.   {
  3.     // fusionamos el formulario de contactos
  4.     $this->mergeForm(new ContactoForm(ContactoPeer::retrieveByPK($this->getObject()->getId())));
  5.    }
  6.  
  7.   /**
  8.   * Actualizamos los formularios agregado
  9.   * en caso de tener varios mergeForm
  10.   * @param string $subform  Nombre de la clase form, ejem. ContactoForm = Contacto
  11.   */
  12.   protected function updateSubform($subform)
  13.   {
  14.       if(!is_null($objectSubform = $this->getObjectSubform($subform)))
  15.       {
  16.     $values = $this->getValues();
  17.    
  18.     if($objectSubform->isNew())
  19.     {
  20.       $values['id'] = $this->object->getId();
  21.     }
  22.     $objectSubform->fromArray($values,BasePeer::TYPE_FIELDNAME);
  23.     $objectSubform->save();
  24.       }
  25.   }
  26.  
  27.   /**
  28.   * Retorna el objeto FichaAsociado, si no existe crea uno
  29.   * @return objeto propel
  30.   */
  31.   protected function getObjectSubform($subform)
  32.   {
  33.     $getSubform = 'get'.$subform;
  34.  
  35.     if(!$this->object->$getSubform())
  36.     {
  37.       return new $subform();
  38.     }
  39.     return $this->object->$getSubform();
  40.   }
  41.  
  42.   /**
  43.   * Reescribimos el método save
  44.   */
  45.   public function save($con = null)
  46.   {
  47.     parent::save();
  48.    
  49.     $this->updateSubform('Contacto');
  50.    
  51.     return $this->object;
  52.   }