【问题标题】:Error when displaying a sfGuardUser显示 sfGuardUser 时出错
【发布时间】:2012-10-02 19:10:25
【问题描述】:

我想在页面中显示会员信息。

这是我的routing.yml

member_show:
  url:   /membres/profil/:id
  class: sfDoctrineRoute
  options: { model: sfGuardUser, type: object }
  param: { module: member, action: show }

这是我的actions.class.php

public function executeShow(sfWebRequest $request)
{
  if($this->getUser()->isAuthenticated())
  {
    $this->member = $this->getRoute()->getObject();
  }
  else
  {
    $this->redirect('@homepage');
  }
}

但我收到此错误:

“sfGuardUser”上的未知记录属性/相关组件“用户”

这是堆栈跟踪:

http://pastebin.com/G1rcLL6r

【问题讨论】:

  • 发布的代码中没有对user 的任何引用。我认为问题出在其他地方,可能在模板中。您可以在堆栈跟踪中看到问题的来源。
  • 能否粘贴您的模板 (showSuccess.php)?
  • getUsername(); ?>

    xxx

  • 正如@1ed 所说,你能粘贴整个堆栈跟踪吗?里面的每一条信息都会把你引向问题
  • 在我的问题中将其作为 pastebin 链接。无法将其粘贴到我的答案中。

标签: php symfony-1.4 sfguard


【解决方案1】:

根据您作为评论发布的堆栈跟踪,您应该在 apps/frontend/modules/member/actions/actions.class.php 的第 59 行写上 $this->getResponse()->setTitle('XX - '.$this->member->getUsername());

【讨论】:

  • @Elwyn 堆栈跟踪总是告诉您问题出在哪里。仔细阅读堆栈跟踪可以解决 90% 的问题 :)
猜你喜欢
  • 2016-04-22
  • 1970-01-01
  • 1970-01-01
  • 2019-07-28
  • 1970-01-01
  • 2013-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多