【发布时间】:2011-04-07 13:34:49
【问题描述】:
我需要为模型列表创建“复制”操作。它应该从某个模型中获取所有值,将它们填充到表单中,您可以只编辑几个字段,然后按“保存”它会创建新模型。目前我考虑合并 Edit 和 New 操作:
public function executeListCopy(sfWebRequest $request)
{
# EDIT
# $this->offer = $this->getRoute()->getObject();
# $this->form = $this->configuration->getForm($this->offer);
# NEW
# $this->form = $this->configuration->getForm();
# $this->offer = $this->form->getObject();
# COPY
<..>
}
编辑部分显示当我使用编辑按钮时交响乐运行的命令。
NEW 与编辑相同只是创建新模型。
我想到了这个:
$this->form = $this->configuration->getForm($this->getRoute()->getObject());
$this->job_offer = $this->form->getObject();
我失败了。这为表单提供了模型 ID,并且由于 id 是预定义的 - 它编辑,而不是创建模型。
我该怎么做?
【问题讨论】:
标签: php symfony1 copy action models