diff --git a/app/models/user.rb b/app/models/user.rb index cfdb87e3d2..5cb44aa085 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,6 +3,7 @@ class User < ApplicationRecord extend Enumerize POSSIBLE_ROLES = %w(account_admin regular) + POSSIBLE_TITLES = %w(Mr Mrs Miss Ms Mx Dr Professor Reverend Sir Baron Baroness Dame Lady Lord) devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :confirmable, diff --git a/app/views/admin/form_answers/company_details/_organisation_head_form.html.slim b/app/views/admin/form_answers/company_details/_organisation_head_form.html.slim index c8df35163e..36bb209950 100644 --- a/app/views/admin/form_answers/company_details/_organisation_head_form.html.slim +++ b/app/views/admin/form_answers/company_details/_organisation_head_form.html.slim @@ -29,9 +29,11 @@ .row .col-md-2 = f.input :head_of_business_title, - as: :string, + as: :select, label: "Title", - input_html: { class: "form-control" } + input_html: { class: "form-control" }, + collection: User::POSSIBLE_TITLES, + include_blank: false .col-md-3 = f.input :head_of_business_first_name, as: :string, diff --git a/app/views/admin/press_summaries/_contact_details_for_press_enquiries_since_2020.html.slim b/app/views/admin/press_summaries/_contact_details_for_press_enquiries_since_2020.html.slim index ad8ca55b72..6c89f2e148 100644 --- a/app/views/admin/press_summaries/_contact_details_for_press_enquiries_since_2020.html.slim +++ b/app/views/admin/press_summaries/_contact_details_for_press_enquiries_since_2020.html.slim @@ -17,9 +17,11 @@ .row .col-md-2 = f.input :title, - as: :string, + as: :select, label: "Title", - input_html: { class: 'form-control' } + input_html: { class: 'form-control' }, + collection: User::POSSIBLE_TITLES, + include_blank: false .row .col-md-8 = f.input :name, @@ -55,4 +57,4 @@ .form-actions.text-right = link_to "Cancel", "#", class: "btn btn-default form-cancel-link if-no-js-hide", data: { element_focus_target: "dismiss" } = f.submit "Save", class: "btn btn-primary form-save-link pull-right" - .clear \ No newline at end of file + .clear diff --git a/app/views/qae_form/_sub_fields_question.html.slim b/app/views/qae_form/_sub_fields_question.html.slim index 284cee70aa..0acc45b2a9 100644 --- a/app/views/qae_form/_sub_fields_question.html.slim +++ b/app/views/qae_form/_sub_fields_question.html.slim @@ -28,13 +28,27 @@ div role="group" id="#{question.key}" - klass <<(QaeFormBuilder::SubFieldsQuestionDecorator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") - input.govuk-input.js-trigger-autosave[ - class=klass - type="text" - id=question.input_name(suffix: sub_field_key) - value=question.input_value(suffix: sub_field_key) - name=question.input_name(suffix: sub_field_key) - autocomplete="off" *possible_read_only_ops - data-word-max=question.sub_fields_words_max - aria-describedby=(@form_answer.validator_errors && @form_answer.validator_errors[question.hash_key] ? "error_for_#{sub_field_key}" : nil ) - ] + - if sub_field_key == :title + select.govuk-select.js-trigger-autosave[ + class=klass + name=question.input_name(suffix: sub_field_key) + id=question.input_name(suffix: sub_field_key) + aria-describedby=(@form_answer.validator_errors && @form_answer.validator_errors[question.hash_key] ? "error_for_#{sub_field_key}" : nil ) + ] + option value='' disabled=true selected=(User::POSSIBLE_TITLES.exclude?(question.input_value(suffix: sub_field_key))) + | Select a title + - User::POSSIBLE_TITLES.each do |option| + option value="#{option}" selected=((question.input_value(suffix: sub_field_key)).to_s == option.to_s) + = option + + - else + input.govuk-input.js-trigger-autosave[ + class=klass + type="text" + id=question.input_name(suffix: sub_field_key) + value=question.input_value(suffix: sub_field_key) + name=question.input_name(suffix: sub_field_key) + autocomplete="off" *possible_read_only_ops + data-word-max=question.sub_fields_words_max + aria-describedby=(@form_answer.validator_errors && @form_answer.validator_errors[question.hash_key] ? "error_for_#{sub_field_key}" : nil ) + ]