Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How can i pass data to another page?

Started by Muut Archive 11 years ago · 6 replies · 598 views
11 years ago

I have a shop-skeleton and i have a button "I want this" in the details page, it redirects to a form page where they can send contact info if they want to buy this item. How can i pass the item ID to that page?

in php I would just use GET or POST but can't manage to do this with grav and twig and markdown...

11 years ago

Really no one can help me do this very basic thing? is there a way to use PHP in twig or md?

11 years ago

Now I have another problem.
Is it possible to populate form dynamically?

I want to add the product name in the form, but the form is made already with form plugin.
Can I update a field with twig?

11 years ago

Not out of the box.
One way to do it is to provide your own templates/forms/default/form.html.twig (the base file that usually defines the form markup) and for example change its markup to

TWIG

{% for field in form.fields %}
    {% set value = form.value(field.name) %}

    {% if field.name == 'name' %}
      {% set value = 'xxxx' %}
    {% endif %}
    <div>
        {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
    </div>
{% endfor %}

and instead of 'xxxx' put your logic to grab the value you want to add.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1350 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4061 9 years ago
Archive · by Muut Archive, 9 years ago
1 2948 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago