# Add anchor link in controller

**URL:** <https://forum.getkirby.com/t/add-anchor-link-in-controller/6414>\
**Category:** Questions\
**Tags:** v2\
**Created:** [January 25, 2017, 6:16pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414 "2017-01-25T18:16:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 25, 2017, 6:16pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/1 "2017-01-25T18:16:08Z")

</div>

hello,

i have used Bastian Allgeiers [Gist](https://gist.github.com/bastianallgeier/c396df7923848912393d) to make a contact form.  
the form is on the bottom of the page so my question:

is it possible to add a “#contactform” anchor to the URL in the controller?  
the page should scroll down to the form again after sending the mail.

Any hints?

```
 // try to send it
 if($email->send()) {
   //go('home');
  $alert = array("Message sent. Thank you.");
 // add the error to the alert list if it failed
 } else {
   $alert = array($email->error());
 }
   }
 }
 return compact('alert');

```

Also the “CSRF” token is always wrong. dunno why. in the form i set it, check the session… it’s ok.  
After sending, in the controller, the CSRF token is changed somewhere and does not match anymore… strange.  
Marked it out for now… 1st question is more important atm.

thx,  
Sven

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [January 25, 2017, 8:50pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/2 "2017-01-25T20:50:47Z")

</div>

No need to put an anchor link in the controller, just put the id of the section in the action attribute, e.g.

```auto
<form class="contact-form" action="<?php echo $site->url()?>/#contact" method="post">

```

---

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 25, 2017, 10:54pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/3 "2017-01-25T22:54:28Z")

</div>

🙇‍♂️

thank you very much!

---

<div class="post-metadata">

**Author:** ![Cuboctaedro](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cuboctaedro/32/6161_2.png) [@Cuboctaedro](https://forum.getkirby.com/u/Cuboctaedro)\
**Post date:** [March 29, 2019, 12:06pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/4 "2019-03-29T12:06:04Z")

</div>

Does this still work in Kirby 3 ? I am trying to the same but the controller does not work if there is an anchor in the action attribute.

---

<div class="post-metadata">

**Author:** ![Cuboctaedro](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cuboctaedro/32/6161_2.png) [@Cuboctaedro](https://forum.getkirby.com/u/Cuboctaedro)\
**Post date:** [March 29, 2019, 12:16pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/5 "2019-03-29T12:16:22Z")

</div>

Apparently it works like that:

`<form class="contact-form" action="<?php echo $site->url()?>#contact" method="post">`

without the `/`

maybe its a Windows thing.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:23pm UTC](https://forum.getkirby.com/t/add-anchor-link-in-controller/6414/6 "2025-02-06T17:23:16Z")

</div>


