From aafd5414531143fa4a4aff2b4baa377b739a256f Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Thu, 20 Feb 2025 08:47:57 +0000 Subject: [PATCH] Fixup: passing error_items Had to switch from `errors_for_input` (which squashes to a string) to `errors_for` (which converts to an array of hashes as expected) The `errors_for_input` class should only really be used by the `input` component (as explained in the commit that introduces the method: https://github.com/alphagov/whitehall/commit/39b42e9d74bcf7f79a8ce8d9d2d42182ac2a1d9d) --- .../corporate_information_pages/_standard_fields.html.erb | 2 +- .../admin/editionable_social_media_accounts/_form.html.erb | 2 +- app/views/admin/editions/_operational_field_fields.html.erb | 2 +- .../admin/news_articles/_news_article_type_fields.html.erb | 2 +- app/views/admin/organisations/_closed_fields.html.erb | 2 +- app/views/admin/organisations/_form.html.erb | 6 +++--- .../admin/publications/_publication_type_fields.html.erb | 2 +- app/views/admin/role_appointments/_form.html.erb | 2 +- app/views/admin/social_media_accounts/_form.html.erb | 2 +- app/views/admin/speeches/_speaker_select_field.html.erb | 2 +- app/views/admin/speeches/_speech_type_fields.html.erb | 2 +- app/views/admin/worldwide_organisation_pages/_form.html.erb | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/admin/corporate_information_pages/_standard_fields.html.erb b/app/views/admin/corporate_information_pages/_standard_fields.html.erb index 7dc4567818c..355422842f1 100644 --- a/app/views/admin/corporate_information_pages/_standard_fields.html.erb +++ b/app/views/admin/corporate_information_pages/_standard_fields.html.erb @@ -8,7 +8,7 @@ name: "edition[corporate_information_page_type_id]", label: "Type", heading_size: "l", - error_message: errors_for_input(edition.errors, :corporate_information_page_type_id), + error_items: errors_for(edition.errors, :corporate_information_page_type_id), include_blank: true, options: corporate_information_page_types(@organisation).map do |type, value| { diff --git a/app/views/admin/editionable_social_media_accounts/_form.html.erb b/app/views/admin/editionable_social_media_accounts/_form.html.erb index d20e8909e08..4fb87f71338 100644 --- a/app/views/admin/editionable_social_media_accounts/_form.html.erb +++ b/app/views/admin/editionable_social_media_accounts/_form.html.erb @@ -7,7 +7,7 @@ name: "social_media_account[social_media_service_id]", heading_size: "l", include_blank: true, - error_message: errors_for_input(social_media_account.errors, :social_media_service_id), + error_items: errors_for(social_media_account.errors, :social_media_service_id), options: SocialMediaService.all.map do |service| { text: service.name, diff --git a/app/views/admin/editions/_operational_field_fields.html.erb b/app/views/admin/editions/_operational_field_fields.html.erb index 6e2cf7c925d..3f62ae84ea8 100644 --- a/app/views/admin/editions/_operational_field_fields.html.erb +++ b/app/views/admin/editions/_operational_field_fields.html.erb @@ -3,7 +3,7 @@ label: "Field of operation (required)", name: "edition[operational_field_id]", heading_size: "l", - error_message: errors_for_input(edition.errors, :operational_field_id), + error_items: errors_for(edition.errors, :operational_field_id), include_blank: true, options: OperationalField.all.map do |operation| { diff --git a/app/views/admin/news_articles/_news_article_type_fields.html.erb b/app/views/admin/news_articles/_news_article_type_fields.html.erb index e9aaf73fce0..eece63b7e85 100644 --- a/app/views/admin/news_articles/_news_article_type_fields.html.erb +++ b/app/views/admin/news_articles/_news_article_type_fields.html.erb @@ -5,7 +5,7 @@ label: "News article type (required)", heading_size: "l", value: edition.news_article_type_id, - error_message: errors_for_input(edition.errors, :news_article_type_id), + error_items: errors_for(edition.errors, :news_article_type_id), include_blank: true, options: NewsArticleType.all.map do |type| { diff --git a/app/views/admin/organisations/_closed_fields.html.erb b/app/views/admin/organisations/_closed_fields.html.erb index 6d2990a884b..c0d44aab37c 100644 --- a/app/views/admin/organisations/_closed_fields.html.erb +++ b/app/views/admin/organisations/_closed_fields.html.erb @@ -3,7 +3,7 @@ name: "organisation[govuk_closed_status]", id: "organisation_govuk_closed_status", heading_size: "m", - error_message: errors_for_input(organisation.errors, :govuk_closed_status), + error_items: errors_for(organisation.errors, :govuk_closed_status), include_blank: true, options: [ { diff --git a/app/views/admin/organisations/_form.html.erb b/app/views/admin/organisations/_form.html.erb index 539a5613c76..7cf2e94aaaf 100644 --- a/app/views/admin/organisations/_form.html.erb +++ b/app/views/admin/organisations/_form.html.erb @@ -42,7 +42,7 @@ name: "organisation[organisation_logo_type_id]", id: "organisation_organisation_logo_type_id", heading_size: "l", - error_message: errors_for_input(organisation.errors, :organisation_logo_type_id), + error_items: errors_for(organisation.errors, :organisation_logo_type_id), include_blank: true, options: OrganisationLogoType.all.map do |logo_type| { @@ -77,7 +77,7 @@ name: "organisation[organisation_brand_colour_id]", id: "organisation_organisation_brand_colour_id", heading_size: "l", - error_message: errors_for_input(organisation.errors, :organisation_brand_colour_id), + error_items: errors_for(organisation.errors, :organisation_brand_colour_id), include_blank: true, options: OrganisationBrandColour.all.map do |brand_colour| { @@ -122,7 +122,7 @@ name: "organisation[organisation_type_key]", id: "organisation_organisation_type_key", heading_size: "l", - error_message: errors_for_input(organisation.errors, :organisation_type_key), + error_items: errors_for(organisation.errors, :organisation_type_key), include_blank: true, options: OrganisationType.in_listing_order.map do |type| { diff --git a/app/views/admin/publications/_publication_type_fields.html.erb b/app/views/admin/publications/_publication_type_fields.html.erb index f8da8ed1684..31d15ebb207 100644 --- a/app/views/admin/publications/_publication_type_fields.html.erb +++ b/app/views/admin/publications/_publication_type_fields.html.erb @@ -5,7 +5,7 @@ label: "Publication type (required)", heading_size: "l", value: edition.publication_type_id, - error_message: errors_for_input(edition.errors, :publication_type_id), + error_items: errors_for(edition.errors, :publication_type_id), include_blank: true, grouped_options: [ [ diff --git a/app/views/admin/role_appointments/_form.html.erb b/app/views/admin/role_appointments/_form.html.erb index 51b31d385e3..32319da887a 100644 --- a/app/views/admin/role_appointments/_form.html.erb +++ b/app/views/admin/role_appointments/_form.html.erb @@ -14,7 +14,7 @@ form.object.new_record? || option[:selected] end, include_blank: form.object.new_record?, - error_message: errors_for_input(form.object.errors, :person_id), + error_items: errors_for(form.object.errors, :person_id), } %> <% if form.object.new_record? %> diff --git a/app/views/admin/social_media_accounts/_form.html.erb b/app/views/admin/social_media_accounts/_form.html.erb index 47c59c7d502..290820cccaf 100644 --- a/app/views/admin/social_media_accounts/_form.html.erb +++ b/app/views/admin/social_media_accounts/_form.html.erb @@ -8,7 +8,7 @@ name: "social_media_account[social_media_service_id]", heading_size: "l", include_blank: true, - error_message: errors_for_input(social_media_account.errors, :social_media_service_id), + error_items: errors_for(social_media_account.errors, :social_media_service_id), options: SocialMediaService.all.map do |service| { text: service.name, diff --git a/app/views/admin/speeches/_speaker_select_field.html.erb b/app/views/admin/speeches/_speaker_select_field.html.erb index 69282a402ff..f8e94aa9b9d 100644 --- a/app/views/admin/speeches/_speaker_select_field.html.erb +++ b/app/views/admin/speeches/_speaker_select_field.html.erb @@ -3,7 +3,7 @@ id: "edition_role_appointment_id", name: "edition[role_appointment_id]", label: "", - error_message: errors_for_input(edition.errors, :role_appointment_id), + error_items: errors_for(edition.errors, :role_appointment_id), include_blank: true, options: taggable_role_appointments_container([edition.role_appointment_id]), } %> diff --git a/app/views/admin/speeches/_speech_type_fields.html.erb b/app/views/admin/speeches/_speech_type_fields.html.erb index 460ed59bdb0..05ffea0b040 100644 --- a/app/views/admin/speeches/_speech_type_fields.html.erb +++ b/app/views/admin/speeches/_speech_type_fields.html.erb @@ -5,7 +5,7 @@ label: "Speech type", heading_size: "l", value: edition.speech_type_id, - error_message: errors_for_input(edition.errors, :speech_type_id), + error_items: errors_for(edition.errors, :speech_type_id), include_blank: true, options: SpeechType.primary.map do |type| { diff --git a/app/views/admin/worldwide_organisation_pages/_form.html.erb b/app/views/admin/worldwide_organisation_pages/_form.html.erb index c190607f733..7869a250d5b 100644 --- a/app/views/admin/worldwide_organisation_pages/_form.html.erb +++ b/app/views/admin/worldwide_organisation_pages/_form.html.erb @@ -9,7 +9,7 @@ name: "worldwide_organisation_page[corporate_information_page_type_id]", label: "Type", heading_size: "l", - error_message: errors_for_input(worldwide_organisation_page.errors, :corporate_information_page_type_id), + error_items: errors_for(worldwide_organisation_page.errors, :corporate_information_page_type_id), include_blank: true, options: corporate_information_page_types(@worldwide_organisation).map do |type, value| {