Grav CMS — A way to pass URL parameters in a frontend form

<form
{% block embed_form_core %}{% endblock %}
{% block embed_form_classes %}{% endblock %}
{% block embed_form_custom_attributes %}{% endblock %}
>
{% block embed_fields %}{% endblock %}
{% block embed_buttons %}{% endblock %}
<script>
const path = window.location.pathname;
document.getElementById('motif').value = decodeURI(path.match(/motif:(.*)/)[1]);
</script>

</form>
title: ‘Motive Form’
form:
name: motive-form
... -
name: motif
label: ‘Motif Nr.’
type: text
id: motif
validate:
required: true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
tangled net

tangled net

thoughts about ridiculously distant topics that go through my head