Hello everyone,
I have difficulties validating if a form is submitted. The functionality should be like: I select an item from the select form and it immediately triggers the submit via javascript this.form.submit()
. The script below works fine if I remove get('submit')
from the if statement. I got that snippet part from Email contact form | Kirby CMS, except my form must be validated on the exact same page instead of another one as the select element is a category filter.
Is the problem that the submit is triggered by javascript because get(βsubmitβ) never gets executed? Wondering what the problem here is. I also got things like this to work before fine with raw PHP and HTML just fine but want it to work the intended kirby way.
I tried POST and GET on formβs method attribute but with no difference in result. In HTML5 form elements can work just fine with no attributes.
Thank you.
...
<?php
if($kirby->request()->is('get') && get('submit')) {
var_dump(get('categories'));
}
?>
...
<form>
<select class="form-select" aria-label="Projektfilterung" name="categories" onchange="this.form.submit()">
...