Form ajax
DEV-NOTES:
-
Add the entry
form-ajaxto the filetemplates/layout/base.html.twig. -
Add required fields in the file
php/Api/Action/Form.phpto validate whatever you want to (server-side validation). -
Add files to
/private/forms/to load different data. DON'T forget to add the paths to the.gitignorefile!
The attribute<form action="">must follow the following schema:
/api/{route}/{path}[/ressource], e.g:/api/forms/newsletter/dummy(note that ressource is optional).
Important:
ressourcecan also be a form field (e.g.:<input type="hidden" name="ressource" value="dummy">) or part of the query (e.g.:?ressource="dummy").
If the GET parameterressourceis set, it will overwrite the value of the ressource inaction.
If the POST parameterressourceis set, it will overwrite the value of the ressource inactionand the corresponding GET parameter (if set).
-
Add the attribute
data-ajax="true"to the<form>to submit the form via ajax. BE -
To edit the feedback messages, change the text in the file
templates/partials/tmpl/form-ajax.html-twig. BE