我的代码库是用 Cakephp 构建的。 我有一个处理“注释”字段的更新按钮。我有一个工作 Controller 更新/写入,可以重定向回页面,因此“困难”部分已完成...
但是:从可用性的角度来看,这会重定向到原始 URL,因此每次都会重定向到页面顶部。
<input>
字段有一个 id,所以我只想使用 anchor 标记链接回它。
这是有效的[ Controller ]:
$this->redirect('/review/index/'.item->getEmployeeId());
我尝试添加以下内容:
$this->redirect('/review/index/'.$item->getEmployeeId().'#'.$item->getEmployeeId());
但是 - 这似乎被删除了...写入仍然有效,但 anchor 被删除了。
对于调试/快速陷阱:我已经测试了原始 URL,它重定向到 <input>
.
还有其他方法可以做到这一点吗?我假设这是 cakephp 的“魔法”,我只是不知道如何附加 anchor 。不过,一些谷歌搜索和 API 似乎并没有弄清楚。
非常感谢。
最佳答案
以下:http://book.cakephp.org/2.0/en/controllers.html#Controller::redirect
使用这个:
$url = array(
'controller' => 'review',
'action' => 'index',
$item->getEmployeeId(),
'#' => $item->getEmployeeId()
);
$this->redirect($url);
关于cakephp - cakephp 中的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17742976/