adding required html field

This commit is contained in:
Beverly Nguyen
2024-12-18 12:40:45 -08:00
parent ca5e5ce04c
commit 1df019e78c
4 changed files with 10 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
{#- a record of other elements that we need to associate with the input using {#- a record of other elements that we need to associate with the input using
aria-describedby for example hints or error messages -#} aria-describedby for example hints or error messages -#}
{% set describedBy = params.describedBy if params.describedBy else "" %} {% set describedBy = params.describedBy if params.describedBy else "" %}
<div class="usa-form-group {%- if params.errorMessage %} usa-form-group--error{% endif %} {%- if params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}" aria-live="polite" role="alert"> <div class="usa-form-group {%- if params.errorMessage %} usa-form-group--error{% endif %} {%- if params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}">
{{ usaLabel({ {{ usaLabel({
html: params.label.html, html: params.label.html,
text: params.label.text, text: params.label.text,
@@ -42,5 +42,7 @@
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %} {%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %} {%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
{%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %} {%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}> {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}
{%- if params.required %} required{% endif %}
/>
</div> </div>

View File

@@ -19,7 +19,6 @@
data-{{ key }}="{{ val }}" data-{{ key }}="{{ val }}"
{% endif %} {% endif %}
{% endfor %} {% endfor %}
novalidate
> >
{{ caller() }} {{ caller() }}
</form> </form>

View File

@@ -13,7 +13,8 @@
safe_error_message=False, safe_error_message=False,
rows=8, rows=8,
extra_form_group_classes='', extra_form_group_classes='',
placeholder='' placeholder='',
required=None
) %} ) %}
<div <div
class="usa-form-group{% if field.errors %} usa-form-group--error{% endif %} {{ extra_form_group_classes }}" class="usa-form-group{% if field.errors %} usa-form-group--error{% endif %} {{ extra_form_group_classes }}"
@@ -56,6 +57,7 @@
rows=rows|string, rows=rows|string,
placeholder=placeholder, placeholder=placeholder,
aria_describedby=field.name+"-error", aria_describedby=field.name+"-error",
required='required' if required else None,
**kwargs **kwargs
) }} ) }}
{% if suffix %} {% if suffix %}

View File

@@ -15,8 +15,6 @@
}) }} }) }}
{% endblock %} {% endblock %}
{% block maincolumn_content %} {% block maincolumn_content %}
{{ page_header('{} text message template'.format(heading_action)) }} {{ page_header('{} text message template'.format(heading_action)) }}
@@ -34,7 +32,8 @@
<div class="tablet:grid-col-9 mobile-lg:grid-col-12" aria-live="polite" role="alert"> <div class="tablet:grid-col-9 mobile-lg:grid-col-12" aria-live="polite" role="alert">
{{ form.name(param_extensions={ {{ form.name(param_extensions={
"extra_form_group_classes": "margin-bottom-2", "extra_form_group_classes": "margin-bottom-2",
"id": "name" "id": "name",
"required": True
}) }} }) }}
{{ textbox( {{ textbox(
form.template_content, form.template_content,
@@ -44,6 +43,7 @@
rows=5, rows=5,
extra_form_group_classes='margin-bottom-1', extra_form_group_classes='margin-bottom-1',
placeholder='Edit me! Check out the Personalization section below for details on cool ((stuff)) you can do with your messages!', placeholder='Edit me! Check out the Personalization section below for details on cool ((stuff)) you can do with your messages!',
required=True
) }} ) }}
{% if current_user.platform_admin %} {% if current_user.platform_admin %}
{{ form.process_type }} {{ form.process_type }}