use regular WTForms DateField for requests dates
This commit is contained in:
10
templates/components/date_input.html
Normal file
10
templates/components/date_input.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% from "components/text_input.html" import TextInput %}
|
||||
|
||||
{% macro DateInput(field, tooltip='', placeholder='', validation='anything', paragraph=False) -%}
|
||||
{% if field.data %}
|
||||
{% set input_value=field.data.strftime("%m/%d/%Y") %}
|
||||
{% else %}
|
||||
{% set input_value=None %}
|
||||
{% endif %}
|
||||
{{ TextInput(field, initial_value=input_value, tooltip=tooltip, placeholder=placeholder, validation=validation, paragraph=paragraph) }}
|
||||
{% endmacro %}
|
@@ -1,12 +1,12 @@
|
||||
{% from "components/icon.html" import Icon %}
|
||||
{% from "components/tooltip.html" import Tooltip %}
|
||||
|
||||
{% macro TextInput(field, tooltip='', placeholder='', validation='anything', paragraph=False) -%}
|
||||
{% macro TextInput(field, tooltip='', placeholder='', validation='anything', paragraph=False, initial_value='') -%}
|
||||
<textinput
|
||||
name='{{ field.name }}'
|
||||
validation='{{ validation }}'
|
||||
{% if paragraph %}paragraph='true'{% endif %}
|
||||
{% if field.data %}initial-value='{{ field.data }}'{% endif %}
|
||||
{% if initial_value or field.data %}initial-value='{{ initial_value or field.data }}'{% endif %}
|
||||
{% if field.errors %}v-bind:initial-errors='{{ field.errors }}'{% endif %}
|
||||
key='{{ field.name }}'
|
||||
inline-template>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
{% from "components/alert.html" import Alert %}
|
||||
{% from "components/text_input.html" import TextInput %}
|
||||
{% from "components/options_input.html" import OptionsInput %}
|
||||
{% from "components/date_input.html" import DateInput %}
|
||||
|
||||
{% block subtitle %}
|
||||
<h2>Details of Use</h2>
|
||||
@@ -76,7 +77,7 @@
|
||||
</transition>
|
||||
|
||||
{{ TextInput(f.dollar_value, validation='dollars', placeholder='$0') }}
|
||||
{{ TextInput(f.start_date, placeholder='MM / DD / YYYY', validation='date') }}
|
||||
{{ DateInput(f.start_date, placeholder='MM / DD / YYYY', validation='date') }}
|
||||
|
||||
</div>
|
||||
</details-of-use>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
{% from "components/alert.html" import Alert %}
|
||||
{% from "components/text_input.html" import TextInput %}
|
||||
{% from "components/options_input.html" import OptionsInput %}
|
||||
{% from "components/date_input.html" import DateInput %}
|
||||
|
||||
{% block subtitle %}
|
||||
<h2>Information About You</h2>
|
||||
@@ -29,5 +30,5 @@
|
||||
{{ OptionsInput(f.service_branch) }}
|
||||
{{ OptionsInput(f.citizenship) }}
|
||||
{{ OptionsInput(f.designation) }}
|
||||
{{ TextInput(f.date_latest_training,tooltip="When was the last time you completed the IA training? <br> Information Assurance (IA) training is an important step in cyber awareness.",placeholder="MM / DD / YYYY", validation="date") }}
|
||||
{{ DateInput(f.date_latest_training,tooltip="When was the last time you completed the IA training? <br> Information Assurance (IA) training is an important step in cyber awareness.",placeholder="MM / DD / YYYY", validation="date") }}
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user