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
aria-describedby for example hints or error messages -#}
{% 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({
html: params.label.html,
text: params.label.text,
@@ -42,5 +42,7 @@
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% 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>

View File

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

View File

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

View File

@@ -15,8 +15,6 @@
}) }}
{% endblock %}
{% block maincolumn_content %}
{{ 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">
{{ form.name(param_extensions={
"extra_form_group_classes": "margin-bottom-2",
"id": "name"
"id": "name",
"required": True
}) }}
{{ textbox(
form.template_content,
@@ -44,6 +43,7 @@
rows=5,
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!',
required=True
) }}
{% if current_user.platform_admin %}
{{ form.process_type }}