18F/identity-idp

View on GitHub
app/views/shared/_ssn_field.html.erb

Summary

Maintainability
Test Coverage
<%#
locals:
* f: from simple_form_for
%>

<%# maxlength set and includes '-' delimiters to work around cleave bug %>
<%= render PasswordToggleComponent.new(
      form: f,
      toggle_label: t('forms.ssn.show'),
      field_options: {
        name: :ssn,
        as: :password,
        label: t('idv.form.ssn_label'),
        hint: t('forms.example') + ' 123-45-6789',
        required: true,
        pattern: '^\d{3}-?\d{2}-?\d{4}$',
        maxlength: 11,
        input_html: { class: 'ssn-toggle', value: f.object.ssn },
        error_messages: { patternMismatch: t('idv.errors.pattern_mismatch.ssn') },
      },
    ) %>

<%= javascript_packs_tag_once('ssn-field') %>