Created
April 9, 2011 05:07
-
-
Save bshaffer/911160 to your computer and use it in GitHub Desktop.
Old Admin: from actions.class.php...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class autoSf_guard_user_oldActions extends sfActions | |
{ | |
// .... | |
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 { | |
$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; | |
} | |
$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_sf_guard_user_old_new'); | |
} | |
else | |
{ | |
$this->getUser()->setFlash('notice', $notice); | |
$this->redirect(array('sf_route' => 'sf_guard_user_sf_guard_user_old_edit', 'sf_subject' => $sf_guard_user)); | |
} | |
} | |
else | |
{ | |
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment