0

我使用 symfony 管理生成器创建了一个用于运动员管理的 Web 应用程序。最后一个客户的要求之一是添加一项功能,以在数据库中插入具有相同号码的运动员时通知用户并向管理员发送电子邮件。到目前为止,Athlete 表的列号有一个唯一的约束,但客户希望运动员无论如何都可以插入。

为此,我试图扩展编辑/新操作以实现客户要求。

这是代码:

public function executeEdit(sfWebRequest $request)
    {
        $user = $this->getUser();

        if(! $user->hasCredential('admin'))
        {

            $clube_id = $user->getAttribute('id');
            $atleta_id = $request->getParameter('id');
            $atleta = Doctrine::getTable('Atleta')->find($atleta_id);

            if($clube_id != $atleta->clube_id)
                $this->forward404();        

        }

        if($request->get('post'))
        {
            // check if the inserted athlete BI already exists; if so, display a message to the user and send an email to the system admins
            $atleta_id = $request->getParameter('id');
            $atletaBIExiste = Doctrine::getTable('Atleta')->findDuplicateAthleteBI($atleta_id);

            if($atletaBIExiste)
            {
                // display a notice message to the user
                $this->getUser()->setFlash('error', 'Athlete already exists');

                // send an email to the system administrator
            }
        }


        return parent::executeEdit($request);
    }

这是我的问题:当我执行编辑操作时,我只想在 HTTP 为 POST 时检查重复的运动员编号,但似乎从来没有。我已经向输出发送了一些异常来验证哪种类型是 HTTP 请求,并且它似乎总是 GET。

4

1 回答 1

2

您将遇到的问题是,当您在编辑页面上点击保存时,信息不会发布到编辑操作,而是发布到名为更新的操作。

查看缓存中的 actions.class.php 文件,您会看到它。

于 2010-06-24T10:06:32.137 回答