0

在我看来,我有这行代码

<a href="<?php echo $this->url.'/login/calllogs/id/'.$record->phone_service_id;?>">Control Panel</a>

在我的登录控制器中我有这个动作

public function calllogsAction(){
    if(!Zend_Auth::getInstance()->hasIdentity()){
        $this->_redirect('login/login');
    } else{
        $request = $this->getRequest();
        $this->view->assign('url', $request->getBaseURL());
    }
}

如何$record->phone_service_id;在我的操作 ( ) 中获取我的视图变量 ( calllogsAction)?我没有提交,这只是一个链接。我想我不能在我的行动 calllogsAction 中这样做

$request = $this->getRequest();
$phone_service_id =  $request->getParam("id");
4

2 回答 2

1

事实证明,最初的答案与您的尝试相同。

如果您不想在地址栏中显示 id(请记住,如果他们拥有正确的工具,任何人都可以看到发布数据),那么您的另一个选择是使用带有表单的 POST -

<form action="<?php echo $this->url.'/login/calllogs/id';?>" method="post">
<input type="hidden" name="id" value="<?php echo $record->phone_service_id; ?>" />
<input type="submit" name="submit" value="Control Panel" />
</form>

然后,您需要在控制器中使用 getPost 而不是 getParam 来获取变量。

于 2012-01-31T09:48:11.003 回答
1

如果您不希望 id 显示在地址栏中,则必须使用 POST。采用

<form method="post" action="<?php /*your URL here*/ ?>">

而不是一个简单的链接,在表单内:

<input type="hidden" name="id" value="<?php /*your id here*/ ?>"/>

并在控制器中使用

$id = $this->getRequest()->getPost("id");
于 2012-01-31T10:07:41.973 回答