Redirect the user to the exact same spot within a page, where (s)he previously left off from

Hello, everyone!

I’m a beginner to CakePHP and I’m very excited to to work with it too, I started reading the documentation a few days ago!

And decided to work on an application, so in it, I have a list of records which I edit repeatedly.

Problem : Whenever I work on a particular record and save my work, the web page returns me to the top of the page.
Expected Result : After saving my work, I need to return at the exact same spot where I made the edited previously.

Is there any Cake-ish way to achieve this? I have no clue how to get this done, I searched on google but no luck yet.

I would really appreciate if anyone can help me with this, thanks a lot!

You mean a form? And it should go back to showing whatever field you just edited? What if you change multiple fields?

You will want to have HTML tags with id attributes at the various return points in your page. And the action attribute for the form you are submitting will need to include the id anchor you want to return to after submitting.

This is a pretty unusual page behavior, but technically possible.

From your description it sounds like you have a series of forms:

<form action="url#anchor1">
// form inputs here
// submit button
</form>

<form action="url#anchor2" id="anchor1">
// form inputs here
// submit button
</form>

<form action="url#anchor3" id="anchor2">
// form inputs here
// submit button
</form>

Now when each form gets submitted, the url (and so the Request object in your application) will include the name of the point on the page you want to go to.

You can see the idea of url anchors in the url:

https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method

The part after the # symbol is the id of an element on the page (in this case an h3 tag)

<h3>The Change Method<a class="headerlink" href="#the-change-method" title="Permalink to this headline">¶</a></h3>

Ah, but i see the modern usage may be ‘href’ rather than ‘id’ though both should work.