0
快速提问。我使用symfony1.4与Doctrine ORM和sfGuardDoctrinePlugin。我有一个名为'任务'的symfony表单。我希望将userId字段(如果用户表的FK设为Id)默认设置为当前记录的用户。我怎样才能做到这一点?将userId设置为从默认设置为当前用户
//apps/myapp/modules/task/actions
class taskActions extends sfActions
{
public function executeNew(sfWebRequest $request)
{
$this->form = new taskForm();
}
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$this->form = new taskForm();
$this->processForm($request, $this->form);
$this->setTemplate('new');
}
}
对不起,没有启动问题的权利。以下是通过操作初始化表单的代码。我真正想要的是将当前用户传递给表单。 – 2012-04-19 02:00:42
不用担心。用一种方式更新后的职位。 – 2012-04-19 02:12:03