govuk_design_system_formbuilder 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c55b78722270c864a735be507e018c420e14bee0e408c59da1bc61777c320bf7
4
- data.tar.gz: b0d291bca6a13a77fe21db5c431bfea86184de8acd82b5e4cc3a3c944fdf322c
3
+ metadata.gz: 7450c096f60fc5960a22c6fa4012c478cd34dbe86bdd1b0fe09e034ad965422c
4
+ data.tar.gz: 62011bc3b81778fb0efc042fc9b04107b36ea69926ee23ba92044606d0f09601
5
5
  SHA512:
6
- metadata.gz: a130e8bb5964af17acb89a14f02ecda2ed989c1e18c6ed970a400945be78c5a8fdc0dd735333b026f51b75a5d090c4e6403f3594feedf595b21c294abec13ae7
7
- data.tar.gz: 9afc6f6e12e26bdc2cd4eafc41f2d1e5a972829fd18bd2a2571550b683500320a66f6603d159af0e7c0943b57deeaf8b47267499ac4cf2c3577d207b555cfcba
6
+ metadata.gz: 9bb6242f2b97c9912d25748d07b25a2650a3bb85aaf168e73ff268caef449dda20d99df4ebcd3f460be90ba82c593be3f6732dff2640ac457b0020471676e894
7
+ data.tar.gz: 0f0b32faf4869aa47897e2f5acb517af84992726d1a8b52916f0670999afe284bef3112716416cfbb3f53e806364337ecdac560e5a7a0b9ff7e5a64e53cef2eb
@@ -880,6 +880,8 @@ module GOVUKDesignSystemFormBuilder
880
880
  # part of the form that contains the error
881
881
  #
882
882
  # @param title [String] the error summary heading
883
+ # @param link_base_errors_to [Symbol,String] set the field that errors on +:base+ are linked
884
+ # to, as there won't be a field representing the object base.
883
885
  #
884
886
  # @note Only the first error in the +#errors+ array for each attribute will
885
887
  # be included.
@@ -888,8 +890,8 @@ module GOVUKDesignSystemFormBuilder
888
890
  # = f.govuk_error_summary 'Uh-oh, spaghettios'
889
891
  #
890
892
  # @see https://design-system.service.gov.uk/components/error-summary/ GOV.UK error summary
891
- def govuk_error_summary(title = config.default_error_summary_title)
892
- Elements::ErrorSummary.new(self, object_name, title).html
893
+ def govuk_error_summary(title = config.default_error_summary_title, link_base_errors_to: nil)
894
+ Elements::ErrorSummary.new(self, object_name, title, link_base_errors_to: link_base_errors_to).html
893
895
  end
894
896
 
895
897
  # Generates a fieldset containing the contents of the block
@@ -3,10 +3,11 @@ module GOVUKDesignSystemFormBuilder
3
3
  class ErrorSummary < Base
4
4
  include Traits::Error
5
5
 
6
- def initialize(builder, object_name, title)
7
- @builder = builder
8
- @object_name = object_name
9
- @title = title
6
+ def initialize(builder, object_name, title, link_base_errors_to:)
7
+ @builder = builder
8
+ @object_name = object_name
9
+ @title = title
10
+ @link_base_errors_to = link_base_errors_to
10
11
  end
11
12
 
12
13
  def html
@@ -54,7 +55,11 @@ module GOVUKDesignSystemFormBuilder
54
55
  end
55
56
 
56
57
  def field_id(attribute)
57
- build_id('field-error', attribute_name: attribute)
58
+ if attribute.eql?(:base) && @link_base_errors_to.present?
59
+ build_id('field', attribute_name: @link_base_errors_to)
60
+ else
61
+ build_id('field-error', attribute_name: attribute)
62
+ end
58
63
  end
59
64
 
60
65
  def summary_title_id
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_design_system_formbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Yates
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-03 00:00:00.000000000 Z
11
+ date: 2020-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -303,7 +303,7 @@ metadata:
303
303
  documentation_uri: https://www.rubydoc.info/gems/govuk_design_system_formbuilder/GOVUKDesignSystemFormBuilder/Builder
304
304
  homepage_uri: https://govuk-form-builder.netlify.app
305
305
  source_code_uri: https://github.com/DFE-Digital/govuk_design_system_formbuilder
306
- post_install_message:
306
+ post_install_message:
307
307
  rdoc_options: []
308
308
  require_paths:
309
309
  - lib
@@ -319,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
319
  version: '0'
320
320
  requirements: []
321
321
  rubygems_version: 3.1.2
322
- signing_key:
322
+ signing_key:
323
323
  specification_version: 4
324
324
  summary: GOV.UK-compliant Rails form builder
325
325
  test_files: []