0
我還需要在symfony中創建複製動作。我已經看過這些問題和答案:symfony 1.4: creating "Copy" action。它似乎工作正常,但是當我嘗試保存獲取這些錯誤消息:「csrf標記:檢測到CSRF攻擊」。我認爲這是因爲我不知道在哪裏更改表單屬性操作。在symfony 1.4中複製動作
任何幫助非常感謝!
這裏是我的代碼:
的actions.class.php:
class eventActions extends autoEventActions {
public function executeCopy(sfWebRequest $request)
{
$this->form = new EventCopyForm($this->getRoute()->getObject());
$this->event = $this->form->getObject();
$this->setTemplate('copy');
}
public function executeUpdatecopy(sfWebRequest $request)
{
$this->form = new EventCopyForm($this->getRoute()->getObject());
$this->processForm($request, $this->form);
$this->setTemplate('copy');
}
}
EvenCopyForm.class.php:
class EventCopyForm extends EventForm {
public function doSave($conn = null)
{
$this->updateObject();
$event = $this->getObject()->copy();
$event->save();
}
}
copySuccess.php:
<?php use_helper('I18N', 'Date') ?>
<?php include_partial('event/assets') ?>
<div id="sf_admin_container">
<h1><?php echo __('Copy Event', array(), 'messages') ?></h1>
<?php include_partial('event/flashes') ?>
<div id="sf_admin_header">
<?php include_partial('event/form_header', array('event' => $event, 'form' => $form, 'configuration' => $configuration)) ?>
</div>
<div id="sf_admin_content">
<?php include_partial('event/form', array('event' => $event, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
</div>
<div id="sf_admin_footer">
<?php include_partial('event/form_footer', array('event' => $event, 'form' => $form, 'configuration' => $configuration)) ?>
</div>
</div>