| 1 |
lars |
1 |
protected function processForm(sfWebRequest $request, sfForm $form)
|
|
|
2 |
{
|
|
|
3 |
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
|
|
|
4 |
if ($form->isValid())
|
|
|
5 |
{
|
|
|
6 |
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
|
|
|
7 |
|
|
|
8 |
$<?php echo $this->getSingularName() ?> = $form->save();
|
|
|
9 |
|
|
|
10 |
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $<?php echo $this->getSingularName() ?>)));
|
|
|
11 |
|
|
|
12 |
if ($request->hasParameter('_save_and_add'))
|
|
|
13 |
{
|
|
|
14 |
$this->getUser()->setFlash('notice', $notice.' You can add another one below.');
|
|
|
15 |
|
|
|
16 |
$this->redirect('@<?php echo $this->getUrlForAction('new') ?>');
|
|
|
17 |
}
|
|
|
18 |
else
|
|
|
19 |
{
|
|
|
20 |
$this->getUser()->setFlash('notice', $notice);
|
|
|
21 |
|
|
|
22 |
$this->redirect(array('sf_route' => '<?php echo $this->getUrlForAction('edit') ?>', 'sf_subject' => $<?php echo $this->getSingularName() ?>));
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
else
|
|
|
26 |
{
|
|
|
27 |
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
|
|
|
28 |
}
|
|
|
29 |
}
|