0

尝试添加新模块页面时出现 404。作为 Symfony 的新手,我显然在这里遗漏了一些基本的东西。谁能指出我错过了什么?

非常感谢。


模块/admin/actions/actions.class.php

/* following executeIndex() */

public function executeSchedule()
{
    if ($this->getRequest()->getethod() != sfRequest::POST)
    {
        return sfView::SUCCESS;
    }
    else
    {
        $name = $this->getRequestParameter('first_name');
        echo $name;
    }
}

模块/管理员/模板/scheduleSuccess.php

<?=set_title('Schedule')?>

<form action="/admin/schedule" method="POST">
<input name="foo" type="text">
<?php echo submit_tag('Schedule'); ?></p

提交后,我收到此错误:

Sep 28 10:02:37 symfony [info] {sfAction} call "defaultActions->executeError404()"
Sep 28 10:02:37 symfony [warning] {404} requested url: /admin/schedule
Sep 28 10:02:37 symfony [info] {sfView} initialize view for "default/error404"
4

2 回答 2

1
  1. 永远不要硬编码 url,使用 url_for 之类的帮助程序。
  2. 使用表单框架。
  3. 阅读教程:http ://www.symfony-project.org/jobeet/1_2/Doctrine/en/
于 2009-09-28T19:02:06.847 回答
1

另外,不要在你的行为中附和。使用 setContent 帮助器。

在你的情况下:

$name = $this->getRequestParameter('first_name');
$this->getResponse()->setContent($name);
于 2009-09-30T01:59:30.313 回答