Symfony:添加新的操作/视图错误。 (新手问题)

发布于 2024-08-05 20:39:57 字数 978 浏览 3 评论 0原文

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

非常感谢。


module/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;
    }
}

module/admin/templates/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"

I'm getting a 404 when trying to add a new module page. I'm apparently missing something fundamental here, being a newbie to Symfony. Can anyone point out what it is I'm missing?

Many thanks.


modules/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;
    }
}

modules/admin/templates/scheduleSuccess.php

<?=set_title('Schedule')?>

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

Upon submit, I get this error:

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-08-12 20:39:57
  1. 永远不要硬编码 url,使用像 url_for 这样的助手。
  2. 使用表单框架。
  3. 阅读教程:http://www.symfony-project.org/jobeet/ 1_2/学说/en/
  1. Never hard code urls, use helpers like url_for.
  2. Use forms framework.
  3. Read tutorial: http://www.symfony-project.org/jobeet/1_2/Doctrine/en/
旧伤还要旧人安 2024-08-12 20:39:57

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

在你的情况下:

$name = $this->getRequestParameter('first_name');
$this->getResponse()->setContent($name);

Also, don't echo in your actions. Use the setContent helper.

In your situation:

$name = $this->getRequestParameter('first_name');
$this->getResponse()->setContent($name);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文