how to build form_ajax() function with data-request-validate attribute
Ad
I need to use the form_ajax twig function to build my opening form tag (I want to use this function to benefit from the security token)
So my correct tag in raw html is
<Form class = "participant" data-request = "onAddToBasket" data-request-validate id = "form-add-to-basket">
With form_ajax, I have this line that works
{{ form_ajax('onAddToBasket', { id: 'form-add-to-basket' }) }}
But now I have to add the data-request-validate attribute and I do not know how to do it (I did not find it in the documentation nor in the search engines)
I tried several random combo but obviously I can not invent the correct syntax by myself :-)
any idea ? thanks for help
Ad
Answer
Ad
You can add it the same way you added the id attribute.
{{ form_ajax('onAddToBasket', { id: 'form-add-to-basket', 'data-request-validate': true }) }}
Ad
source: stackoverflow.com
Related Questions
Ad
- → OctoberCMS Backend Loging Hash Error
- → "failed to open stream" error when executing "migrate:make"
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → Create plugin that makes objects from model in back-end
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → How to install console for plugin development in October CMS
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → October CMS - Conditionally Load a Different Page
Ad