public function editAction() { $form = new SimpleCal_Form_Event(array('action' => $this->view->baseUrl . '/event/edit')); $form->populate($this->_getAllParams()); if ($this->getRequest()->isPost()) { $params = $this->_getAllParams(); if ($form->isValid($params)) { $event = SimpleCal_Model_Event::getInstanceByForm($form); $event->save(); if ($month = $event->getStartTimeMonth()) { $this->_redirect("/month/{$month}", array('exit' => false)); } else { $this->_redirect('/', array('exit' => false)); } $this->_setParam('event_id', $event->getId()); $this->_forward('invitation'); return; } } elseif ($eventId = $this->_getParam('id')) { $event = SimpleCal_Model_Event::getInstanceById($eventId); $form->populate($event->getFormContainer()); } $this->view->form = $form; }
public static function getInstanceByForm(SimpleCal_Form_Event $form) { $data = $form->getValues(); $startTime = strtotime($data['date'] . " " . $data['time']); $data['start_time'] = $startTime; $data['end_time'] = $startTime + 1800; // TODO: Implement this! return new self($data); }