xpertbot / craft-wheelform

Craft CMS 4 Form with Database integration
MIT License
66 stars 32 forks source link

Check if form is active before submit #306

Closed hotnunstar closed 8 months ago

hotnunstar commented 8 months ago

Hello.

I would like to know if it is possible to check if a form is inactive before submitting it.

If I use wheelformErrors, I only see information that the form is inactive after submission, but I wanted to prevent the user from filling in and submitting the form when it is inactive.

xpertbot commented 8 months ago

Wheelform frontend is framework agnostic. Therefore, this check needs to be done by the developer using Javascript or through the templates.

I added a new isActive() method to the FormService on the templates. You can add it as an attribute to the form HTML.

{% set form = wheelform.form({id: 1}) %}
{{ form.open('', {
    'data-form-active': form.isActive() ? '1' : '0',
}) }}

I hope this helps.

hotnunstar commented 8 months ago

I'm using Craft 3.x so I needed to do the changes to an older plugin version but it works.

Thank you!