I am new to Craft and Twig in general. I have encountered the following problems and struggling to find a solution for hours.
- I want to access the value of "foo" input field inside the twig delimiters to set the "json" variable.
- I want to change the "clicked" boolean, whenever the submit button is clicked.
The myFunc is a function that I am using from a custom plugin so it is not relative. I have commented what I've last tried and does not work for me.
I am using Craft 3, if that helps.
{% block body %}
{% set clicked = false %}
<form name="search" action="{% set clicked = true %}">
<label for="foo">Foo</label>
<input name="foo" type="text"/>
<input type="submit" value="Get Json"/>
{# <a href="{{ set clicked = true }}"#}
</form>
{% if clicked %}
{% set json = jsonator_myFunc(search.foo.vars.value) %}
{% endif %}
{% endblock %}
EDIT/SOLUTION:
A few more days into Craft CMS and chill and I realize how silly my question is.
Thank you for the replies. The solution which I was looking for is:
craft.request.getParam('foo')