/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new EventForm(); if (isset($_POST['EventForm'])) { $model->attributes = $_POST['EventForm']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Обработка формы * * @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; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = new EventForm('view', $id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['EventForm'])) { $model->attributes = $_POST['EventForm']; $model->postItem->attributes = $_POST['PostItem']; $model->event->attributes = $_POST['Event']; if ($model->validate() && $model->save()) { $this->redirect(array('view', 'id' => $model->event->post_item_id)); } } $this->render('update', array('model' => $model)); }