/**
  * Обработка формы
  *
  * @param EventForm $form
  * @param sfWebRequest $request
  */
 protected function processForm(EventForm $form, sfWebRequest $request)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $event = $form->save();
         if ($request->isXmlHttpRequest()) {
             $event = EventTable::getInstance()->queryWithCount(null, 'e')->where('e.id = ?', $event->id)->fetchOne();
             return $this->renderPartial('event/show', array('event' => $event));
         } else {
             return $this->redirect('event_show', $event);
         }
     }
     return sfView::SUCCESS;
 }
 /** Edit an event
  */
 public function editAction()
 {
     $form = new EventForm();
     $form->details->setLegend('Edit event');
     $form->submit->setLabel('Save event');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $address = $form->getValue('eventLocation');
             $coords = $this->_geocoder->getCoordinates($address);
             if ($coords) {
                 $lat = $coords['lat'];
                 $long = $coords['lon'];
                 $pm = new Pas_Service_Geoplanet();
                 $place = $pm->reverseGeoCode($lat, $lon);
                 $woeid = $place['woeid'];
             } else {
                 $lat = NULL;
                 $lon = NULL;
                 $woeid = NULL;
             }
             $insertdata = array('eventTitle' => $form->getValue('eventTitle'), 'eventDescription' => $form->getValue('eventDescription'), 'eventLocation' => $form->getValue('eventLocation'), 'organisation' => $form->getValue('organisation'), 'eventStartTime' => $form->getValue('eventStartTime'), 'eventEndTime' => $form->getValue('eventEndTime'), 'eventStartDate' => $form->getValue('eventStartDate'), 'eventEndDate' => $form->getValue('eventEndDate'), 'eventRegion' => $form->getValue('eventRegion'), 'eventType' => $form->getValue('eventType'), 'latitude' => $lat, 'longitude' => $long, 'adultsAttend' => $form->getValue('adultsAttend'), 'childrenAttend' => $form->getValue('childrenAttend'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
             foreach ($insertdata as $key => $value) {
                 if (is_null($value) || $value == "") {
                     unset($insertdata[$key]);
                 }
             }
             $events = new Events();
             $where = array();
             $where[] = $events->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
             $events->update($insertdata, $where);
             $this->_flashMessenger->addMessage('You updated: <em>' . $form->getValue('eventTitle') . '</em> successfully.');
             $this->_redirect('/admin/events/');
         } else {
             $form->populate($formData);
         }
     } else {
         $id = (int) $this->_getParam('id', 0);
         if ($id > 0) {
             $events = new Events();
             $event = $events->fetchRow('id=' . (int) $id);
             $form->populate($event->toArray());
         }
     }
 }
 /** Edit an event
  * @access public
  * @return void
  * @todo Add geocoding in model
  */
 public function editAction()
 {
     $form = new EventForm();
     $form->details->setLegend('Edit event');
     $form->submit->setLabel('Save event');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $where = array();
             $where[] = $this->_events->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
             $this->_events->update($form->getValues(), $where);
             $this->getFlash()->addMessage('You updated this events successfully.');
             $this->redirect('/admin/events/');
         } else {
             $form->populate($this->_request->getPost());
         }
     } else {
         $form->populate($this->_events->fetchRow('id=' . $this->getParam('id'))->toArray());
     }
 }