sry juz podaje kod:
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post') && $request->hasParameter('party'));
$this->form = new TpPartyForm();
$this->processForm($request, $this->form);
$this->setTemplate('new');
}
public function executeEdit(sfWebRequest $request)
{
$tp_party = $this->getRoute()->getObject();
$this->getResponse()->setTitle($this->getResponse()->getTitle().' - Edytuj imprezę');
if($this->getUser()->getGuardUser()->getId() == $tp_party->getOwner())
{
$this->form = new TpPartyForm($this->getRoute()->getObject());
}
elseif($this->getUser()->getGuardUser()->getId() !== $tp_party->getOwner())
{
return $this->forward404();
}
}
public function executeUpdate(sfWebRequest $request)
{
//$this->forward404Unless($request->isMethod('post'));
$tp_party = $this->getRoute()->getObject();
if($this->getUser()->getGuardUser()->getId() == $tp_party->getOwner())
{
$this->form = new TpPartyForm($tp_party);
$this->processForm($request, $this->form);
$this->setTemplate('Edit');
}
elseif($this->getUser()->getGuardUser()->getId() !== $tp_party->getOwner())
{
return $this->forward404();
}
$this->setTemplate('edit');
rotected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$tp_party = $form->save();
$this->redirect('myaccount_party_organize_party');
}
}
}
to jest routing:
myaccount_party_create:
url: /account-party/create
class: sfPropelRoute
options: { model: TpParty, type: object }
param: { module: myaccount_party, action: Create }
myaccount_party_edit:
url: /account-party/:token/edit
class: sfPropelRoute
options: { model: TpParty, type: object, column: token}
param: { module: myaccount_party, action: Edit }
requirements:
token: \w+
myaccount_party_update:
url: /account-party/:token/update
class: sfPropelRoute
options: { model: TpParty, type: object, column: token }
param: { module: myaccount_party, action: Update }
requirements:
sf_method: [put]
token: \w+
we formularzu sie tak odnosze to akcji:
form action
="getObject()->isNew() ? '@myaccount_party_create' : '@myaccount_party_update').(!$form->getObject()->isNew() ? '?token='.$form->getObject()->getToken() : '')) ?>" method
="post" isMultipart
() and
print 'enctype="multipart/form-data" ' ?>>getObject()->isNew()): ?>