I need to create a hidden form field and populate the previous and current URL can someone tell me how I can do that in Craft.


In the context of Craft 3,

<input type="hidden" name="referrerUrl" value="{{ craft.app.request.getReferrer()" />

<input type="hidden" name="currentUrl" value="{{ craft.app.request.getAbsoluteUrl() }}" />

You can see other methods off of the web/Request object you can use here: https://docs.craftcms.com/api/v3/craft-web-request.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.