GRAV form submit in modular page

I have successfully implemented contact from in a modular page. However when I submit the form the page gets reloaded, since the form action is the same page. Instead of that I would like to get a json response, based on which a message will be shown to the user. I found a form json twig file, but could not get its use.

It’s not currently possible to force JSON ouput. The URL itself needs to end with .json for that to happen. An issue has been submitted. You could maybe change the form action to redirect to the page with a .json extension and see if that fixes it, though.

Just added this capability: https://github.com/getgrav/grav/commit/c0c77fff671a693be40cabbfc6d63591fdab7999

Thanks for your reply and sorry for being late. I have checked the url you have provided. And sorry again for being dumb, as I could not get what I need to do. Can you please provide some sample code.

it’s in the docs here

Thanks for reply. I will check the documents.