elb98rm
elb98rm

Reputation: 800

Anchor tags in cakephp

My codebase is built in Cakephp. I have an update button which processes a "notes" field. I have a working controller update/write that redirects back to the page, so the "hard" bit is done...

However: from a usability point of view, this redirects to the raw URL, and hence to the top of the page every time. The <input> field has an id, so I simply want to link back to it using an anchor tag.

Here's what works [controller]:

$this->redirect('/review/index/'.item->getEmployeeId());

I tried to add in the following:

$this->redirect('/review/index/'.$item->getEmployeeId().'#'.$item->getEmployeeId());

However - this seems to be stripped out... The write still works, but the anchor is stripped out.

For debugging/quick gotchas: I have tested the raw URL out and it redirects to the <input>.

Is there another way to do this? I'm assuming this is some cakephp "magic" and I simply don't know how to apend an anchor. Some google searches and poking in the API don't seem to clear things up though.

Many thanks.

Upvotes: 2

Views: 2068

Answers (1)

mark
mark

Reputation: 21743

Following: http://book.cakephp.org/2.0/en/controllers.html#Controller::redirect

Use this:

$url = array(
    'controller' => 'review',
    'action' => 'index',
    $item->getEmployeeId(),
    '#' => $item->getEmployeeId()
);
$this->redirect($url);

Upvotes: 2

Related Questions