Disable SaveButton if form is invalid

This commit is contained in:
George Drummond 2019-05-03 14:53:02 -04:00
parent 334f3d8ed3
commit 0e3217d3ac
No known key found for this signature in database
GPG Key ID: 296DD6077123BF17

View File

@ -1,10 +1,10 @@
{% macro SaveButton(text, element="button", additional_classes="", form=None) -%} {% macro SaveButton(text, element="button", additional_classes="", form=None) -%}
{% set class = "usa-button usa-button-primary" + additional_classes %} {% set class = "usa-button usa-button-primary" + additional_classes %}
{% if element == "button" %} {% if element == "button" %}
<button type="submit" class="{{ class }}" tabindex="0" v-bind:disabled="!changed" {{ form_attr }} > <button type="submit" class="{{ class }}" tabindex="0" v-bind:disabled="!changed || invalid" {{ form_attr }} >
{{ text }} {{ text }}
</button> </button>
{% elif element == 'input' %} {% elif element == 'input' %}
<input type="submit" class="{{ class }}" tabindex="0" v-bind:disabled="!changed" value="{{ text }}" {% if form %}form="{{ form }}"{% endif %} /> <input type="submit" class="{{ class }}" tabindex="0" v-bind:disabled="!changed || invalid" value="{{ text }}" {% if form %}form="{{ form }}"{% endif %} />
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}