【发布时间】:2011-08-07 21:08:17
【问题描述】:
我还需要在 symfony 中创建一个复制操作。我已经看过这些问答:symfony 1.4: creating "Copy" action。它似乎工作正常,但是当我尝试保存这些错误消息时:“csrf token: CSRF attack detected”。我估计是因为我不知道在哪里更改表单属性操作。
非常感谢任何帮助!
这是我的代码:
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>
【问题讨论】:
标签: copy action symfony-1.4