Skip to content

Commit

Permalink
required without alpine dynamic, copy email setup, need to double che…
Browse files Browse the repository at this point in the history
…ck form required overlaid by alpine dynamic case
  • Loading branch information
hdaws committed Jan 12, 2025
1 parent 063f60a commit 05a9a77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
20 changes: 11 additions & 9 deletions uber/templates/forms/attendee/personal_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
international: {{ personal_info.international.data | javascript_bool }},
dealer: {{ (is_prereg_dealer or attendee.is_dealer) | javascript_bool }},
noCellphone: {{ personal_info.no_cellphone.data | javascript_bool }},
copyEmail: {{ (group and loaded_from_group and attendee.email == group.email_address) | javascript_bool }},
get isEmailRequired() { return !this.copyEmail },
copyAddress: false,
copyCellphone: false,
get isZipRequired(){ return !this.international && !this.copyAddress && !this.badge_placeholder }, //hmd todo broken and not sure why.
get isZipRequired(){ return !this.international && !this.copyAddress && !this.badge_placeholder },
get isCellphoneDisabled() { return this.noCellphone || this.copyCellphone},
get isCellphoneRequired() { return (this.staffing || this.dealer) && !this.noCellphone && !this.copyCellphone && !this.badge_placeholder } //this is also similarly broken.
get isCellphoneRequired() { return (this.staffing || this.dealer) && !this.noCellphone && !this.copyCellphone && !this.badge_placeholder }
}">
{% block name %}
{% set attendee_last_name = attendee.last_name[0] ~ '.' if limited_read else attendee.last_name %}

<div class="row g-sm-3">
<div class="col-12 col-sm-6">{{ form_macros.form_input(personal_info.first_name) }}</div>
<div class="col-12 col-sm-6">{{ form_macros.form_input(personal_info.last_name, value=attendee_last_name) }}</div>
<div class="col-12 col-sm-6">{{ form_macros.alpine_form_input(personal_info.first_name) }}</div>
<div class="col-12 col-sm-6">{{ form_macros.alpine_form_input(personal_info.last_name, value=attendee_last_name) }}</div>
</div>

{% if attendee.legal_name or attendee.is_new or attendee.placeholder or admin_area %}
Expand All @@ -38,7 +40,7 @@
checked=attendee.first_name != '' and attendee.legal_name == '') }}
</div>

<div class="col-12 col-sm-6">{{ form_macros.form_input(personal_info.legal_name, help_text=macros.popup_link("../static_views/legal_name.html", 'What does "Legal Photo ID" mean?')) }}
<div class="col-12 col-sm-6">{{ form_macros.alpine_form_input(personal_info.legal_name, help_text=macros.popup_link("../static_views/legal_name.html", 'What does "Legal Photo ID" mean?')) }}
</div>
</div>
{% else %}
Expand All @@ -58,13 +60,13 @@

{% block contact_info %}
{% set attendee_email = attendee.masked_email if limited_read else attendee.email %}
{% if is_prereg_dealer %}
{% set email_extra_field = form_macros.toggle_checkbox(personal_info.copy_email, [personal_info.email], hide_on_checked=True, toggle_required=True, prop="disabled", checked=group and loaded_from_group and attendee.email == group.email_address) %}
{% endif %}

<div class="row g-sm-3">
<div class="col-12 col-sm-6">
{{ form_macros.form_input(personal_info.email, extra_field=email_extra_field, value=attendee_email) }}
{{ form_macros.alpine_form_input(personal_info.email, value=attendee_email, alpine_props={':required':'isEmailRequired', ':disabled':'copyEmail'}) }}
{% if is_prereg_dealer %}
{{ form_macros.alpine_form_input(personal_info.copy_email, alpine_props={'x-model.boolean':'copyEmail'}) }}
{% endif %}
</div>
{% if c.PREREG_CONFIRM_EMAIL_ENABLED and (attendee.needs_pii_consent or attendee.badge_status == c.PENDING_STATUS) %}
<div class="col-12 col-sm-6">
Expand Down
12 changes: 7 additions & 5 deletions uber/templates/forms/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,16 @@
</script>
{%- endmacro %}

{% macro alpine_form_label(field, label_text='', required_if=None) %}
{% macro alpine_form_label(field, label_text='', required=None, required_if=None) %}
<label for="{{ field.label.field_id }}"
{% for key in kwargs %} {{ key }}="{{ kwargs[key] }}"{% endfor %}>
<span class="form-label">{{ label_text }}</span>
{% if required_if is not none %}
<span>HMD Debug <span x-text="{{ required_if | string }}"></span></span>
<span class="required-indicator text-danger" x-show="{{ required_if }}"> *</span>
{% elif required is not none %}
<span class="required-indicator text-danger"> *</span>
{% endif %}

</label>
{% endmacro %}

Expand Down Expand Up @@ -247,7 +249,7 @@
{% else %}
{{ field(class="form-check-input", checked=field.data, value=1, **custom_kwargs) }}
{% endif %}
{{ alpine_form_label(field, label_text=label_text, required_if=required_if, class="form-check-label") }}
{{ alpine_form_label(field, label_text=label_text, required= field.flags.required, required_if=required_if, class="form-check-label") }}
{{ form_input_extras(field, help_text, admin_text) }}
</div>
{% elif type == 'checkgroup' %}
Expand All @@ -258,13 +260,13 @@
{% elif type == 'select' %}
<div class="form-floating{% if not no_margin %} mb-3{% endif %}">
{{ field(class="form-select", **custom_kwargs) }}
{{ alpine_form_label(field, label_text=label_text, required_if=required_if) }}
{{ alpine_form_label(field, label_text=label_text, required= field.flags.required, required_if=required_if) }}
{{ form_input_extras(field, help_text, admin_text) }}
</div>
{% else %}
<div class="form-floating{% if not no_margin %} mb-3{% endif %}">
{{ field(class="form-control", **custom_kwargs) }}
{{ alpine_form_label(field, label_text=label_text, required_if=required_if) }}
{{ alpine_form_label(field, label_text=label_text, required= field.flags.required, required_if=required_if) }}
{{ form_input_extras(field, help_text, admin_text) }}
</div>
{% endif %}
Expand Down

0 comments on commit 05a9a77

Please sign in to comment.