public function saveCorrelativeCareerSubjectId($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['correlative_career_subject_id'])) { // somebody has unset this widget return; } if (is_null($con)) { $con = $this->getConnection(); } /* First try to delete old correlatives */ $criteria = new Criteria(); $criteria->add(CorrelativePeer::CAREER_SUBJECT_ID, $this->getObject()->getCareerSubjectId()); CorrelativePeer::doDelete($criteria, $con); /* Now set new values */ $values = $this->getValue('correlative_career_subject_id'); if (is_array($values)) { foreach ($values as $value) { $correlative = new Correlative(); $correlative->setCareerSubjectId($this->getObject()->getCareerSubjectId()); $correlative->setCorrelativeCareerSubjectId($value); $correlative->save($con); } } }
public function createCorrelatives() { foreach ($this->getCareerSubjectRelatedByCareerSubjectId()->getCorrelatives() as $correlative) { $new_correlative = new Correlative(); $new_correlative->setCareerSubjectId($this->getOptionalCareerSubjectId()); $new_correlative->setCorrelativeCareerSubjectId($correlative->getCorrelativeCareerSubjectId()); $new_correlative->save(); } }
public function executeUpdateCorrelatives(sfWebRequest $request) { $this->career_subject = CareerSubjectPeer::retrieveByPK($request->getParameter('id')); if (null === $this->career_subject) { $this->getUser()->setFlash('error', 'Debe seleccionar una materia para editar sus correlativas'); $this->redirect('@career_subject'); } $correlative = new Correlative(); $correlative->setCareerSubjectId($this->career_subject->getId()); $this->form = new CorrelativeForm($correlative); $this->processForm($request, $this->form); $this->setTemplate('editCorrelatives'); }