public function save($con = null) { $schedule = new Schedule(); $schedule->setStartDate($this->getValue('start_date')); $schedule->setEndDate($this->getValue('start_date')); $schedule->setTitle($this->getValue('title')); $schedule->setBody(''); $schedule->setMember(sfContext::getInstance()->getUser()->getMember()); $scheduleMember = new ScheduleMember(); $scheduleMember->setSchedule($schedule); $scheduleMember->setMember($schedule->Member); $scheduleMember->save($con); return $schedule->save($con); }
public function updateObject($values = null) { $object = parent::updateObject($values); foreach ($this->embeddedForms as $key => $form) { $embedded_values = $this->getValue($key); if (!($form->getObject() && $embedded_values['schedule_resource_id'])) { unset($this->embeddedForms[$key]); } } $scheduleMembers = $this->getObject()->getScheduleMembers(); foreach ($scheduleMembers as $scheduleMember) { $scheduleMember->delete(); $scheduleMember->free(); unset($scheduleMember); } $formScheduleMembers = $this->getValue('schedule_member'); foreach ($formScheduleMembers as $formScheduleMember) { $scheduleMember = new ScheduleMember(); $scheduleMember->setSchedule($object); $scheduleMember->setMemberId($formScheduleMember); $scheduleMember->save(); } return $object; }