protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $arquivo = $form->save(); $this->getUser()->setFlash('success', 'Arquivo ' . ($form->isNew() ? 'incluído' : 'alterado') . ' com sucesso!'); $this->redirect('arquivo/index'); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $area_interesse = $form->save(); $this->getUser()->setFlash('success', 'Área de interesse ' . ($form->isNew() ? 'incluida' : 'alterada') . ' com sucesso!'); $this->redirect('areaInteresse/edit?id=' . $area_interesse->getId()); } else { $this->getUser()->setFlash('error', 'O formulário contém erros!', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $curso = $form->save(); $this->getUser()->setFlash('success', 'Curso ' . ($form->isNew() ? 'incluído' : 'alterado') . ' com sucesso!'); $this->redirect('curso/edit?id=' . $curso->getId()); } else { $this->getUser()->setFlash('error', 'O formulário contém erros!', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.'; try { if ($form->isNew() && $form->getValue("password") == "" || is_null($form->getValue("password"))) { throw new Exception("invalid password"); } $sf_guard_user = $form->save(); } catch (Doctrine_Validator_Exception $e) { $errorStack = $form->getObject()->getErrorStack(); $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: "; foreach ($errorStack as $field => $errors) { $message .= "{$field} (" . implode(", ", $errors) . "), "; } $message = trim($message, ', '); $this->getUser()->setFlash('error', $message); return sfView::SUCCESS; } catch (Doctrine_Connection_Mysql_Exception $e) { $message = "An object with this label already exist"; $this->getUser()->setFlash('error', $message); return sfView::SUCCESS; } catch (Exception $e) { $message = "The password is mandatory"; $this->getUser()->setFlash('error', $message); return sfView::SUCCESS; } $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_guard_user))); if ($request->hasParameter('_save_and_add')) { $this->getUser()->setFlash('notice', $notice . ' You can add another one below.'); $this->redirect('@sf_guard_user_new'); } else { $this->getUser()->setFlash('notice', $notice); $route = 'sf_guard_user'; $action = $form->getObject()->isNew() ? 'new' : 'edit'; $redirection = strtolower($this->configuration->getValue($action . '.redirection')); if (isset($redirection) && 'list' !== $redirection) { $route .= '_' . $redirection; } $url = array('sf_route' => $route); if (isset($redirection) && 'list' !== $redirection) { $url['sf_subject'] = $sf_guard_user; } $this->redirect($url); } } else { $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $i18n = sfContext::getInstance()->getI18N(); $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $form->getObject()->setPrincipalId($this->getUser()->getPrincipalId()); $form->getObject()->setType('pending'); $s = $form->getObject(); if (!$form->isNew()) { $this->checkIsMy($form->getObject()); } if ($form->isValid()) { $notice = $form->getObject()->isNew() ? $i18n->__('The service has been created.') : $i18n->__('The service has been updated.'); try { $service = $form->save(); } catch (Doctrine_Validator_Exception $e) { $errorStack = $form->getObject()->getErrorStack(); $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: "; foreach ($errorStack as $field => $errors) { $message .= "{$field} (" . implode(", ", $errors) . "), "; } $message = trim($message, ', '); $this->getUser()->setFlash('error', $message); return sfView::SUCCESS; } if ($form->isNew()) { $sp = new ServicePrincipal(); $sp->setServiceId($form->getObject()->getId()); $sp->setPrincipalId($this->getUser()->getPrincipalId()); $sp->save(); } $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $service))); $this->getUser()->setFlash('notice', $notice); $this->redirect("show/index?id=" . $form->getObject()->getId()); } else { $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $id = $form->getObject()->get('id'); if ($form->isValid()) { $result = $form->save(); if ($form->isNew()) { $this->getUser()->setFlash('mensaje', sfConfig::get('app_mensaje_insertado')); $this->redirect('geografia/estadosInsertar?id=' . $id); } else { $this->getUser()->setFlash('mensaje', sfConfig::get('app_mensaje_modificado')); $this->redirect('geografia/estadosEditar?id=' . $id); } } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $sf_guard_user = $form->save(); if ($form->isNew()) { $data = $request->getPostParameter('sf_guard_user'); $mensaje = Swift_Message::newInstance()->setFrom(sfConfig::get('app_email_sifactadmin'))->setTo($sf_guard_user->getProfile()->getEmail())->setSubject('Datos de registro Sifact')->setBody($this->getPartial('registerConfirmTemplate', array('profile' => $data)), 'text/html'); $this->getMailer()->send($mensaje); $this->redirect('register/register'); } else { $this->getUser()->setFlash('editSuccess', 'Se ha actualizado su perfil con éxito'); $this->redirect('register/edit'); } } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.'; $gc_mailbox = $form->save(); $form->isNew() ? $this->getMailer()->send(new ProjectConfirmationMessage($gc_mailbox->getName(), $gc_mailbox->getEmail())) : $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $gc_mailbox))); if ($request->hasParameter('_save_and_add')) { $this->getUser()->setFlash('notice', $notice . ' You can add another one below.'); $this->redirect('@gc_mailbox_new'); } else { $this->getUser()->setFlash('notice', $notice); $this->redirect(array('sf_route' => 'gc_mailbox_edit', 'sf_subject' => $gc_mailbox)); } } else { $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $professor = $form->save(); if ($request->isMethod(sfRequest::POST)) { $senha = Util::generatePassword(8); $professor->senha = $senha; $professor->save(); //envia a senha por e-mail $email = new SenhaMail($professor->email, array('sender' => $this->getUser()->getAttribute('email', null, 'configuracao'), 'senha' => $senha, 'url' => $this->getUser()->getAttribute('url', null, 'configuracao'))); $email->send(); } $this->getUser()->setFlash('success', 'Professor ' . ($form->isNew() ? 'incluído' : 'alterado') . ' com sucesso!'); $this->redirect('professor/edit?id=' . $professor->getId()); } else { $this->getUser()->setFlash('error', 'O formulário contém erros!', false); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $banca = $form->save(); $this->getUser()->setFlash('success', 'Banca ' . ($form->isNew() ? 'agendada' : 'alterada') . ' com sucesso!'); $this->redirect('banca/edit?id=' . $banca->getId()); } else { $this->getUser()->setFlash('error', 'O formulário contém erros!', false); } }
protected function processForm(sfWebRequest $request, sfForm $form, $action = 'create') { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { try { $wasNew = $form->isNew(); $autoCodeForUpdate = false; if (!$wasNew) { $collection = Doctrine::getTable('Collections')->findOneById($form->getObject()->getCollectionRef()); $autoCodeForUpdate = !$collection->getCodeAutoIncrementForInsertOnly(); } $specimen = $form->save(); if ($wasNew || $autoCodeForUpdate) { Doctrine::getTable('Collections')->afterSaveAddCode($specimen->getCollectionRef(), $specimen->getId()); } $this->redirect('specimen/edit?id=' . $specimen->getId()); } catch (Doctrine_Exception $ne) { if ($action == 'create') { //If Problem in saving embed forms set dirty state $form->getObject()->state('TDIRTY'); } $e = new DarwinPgErrorParser($ne); $extd_message = ''; if (preg_match('/unique constraint "unq_specimens"/i', $ne->getMessage())) { $dup_spec = Doctrine::getTable('Specimens')->findDuplicate($form->getObject()); if (!$dup_spec) { $this->logMessage('Duplicate Specimen not found: ' . json_encode($form->getObject()->toArray()), 'err'); } else { $extd_message = '<br /><a href="' . $this->getController()->genUrl('specimen/edit?id=' . $dup_spec->getId()) . '">' . $this->getI18N()->__('Go the the original record') . '</a>'; } } $error = new sfValidatorError(new savedValidator(), $e->getMessage() . $extd_message); $form->getErrorSchema()->addError($error, 'Darwin2 :'); } } }
/** * @param sfWebRequest $request * @param sfForm $form * @return bool */ protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); /** @var EiDataSetTemplate $object */ $object = $form->getObject(); if ($form->isValid()) { if ($form->isNew()) { // Paramètres liés à l'utilisateur. if ($this->getUser()->getGuardUser()->getEiUser() !== null) { $ref_user = $this->getUser()->getGuardUser()->getEiUser()->getRefId(); $id_user = $this->getUser()->getGuardUser()->getEiUser()->getUserId(); } else { $ref_user = null; $id_user = null; } $object->setRootStr($this->ei_root_structure); $object->setUserRef($ref_user); $object->setUserId($id_user); } $this->getUser()->setFlash('xml_success', 'Update Success ...'); try { $form->save(); } catch (Exception $e) { $this->getUser()->setFlash('xml_error', $e->getMessage()); return false; } return true; } return false; }