Module: GovukDesignSystem::ComponentsHelper

Defined in:
app/helpers/govuk_design_system/components_helper.rb

Instance Method Summary collapse

Instance Method Details

#get_attribute_id_prefix(form, attribute) ⇒ Object



8
9
10
11
# File 'app/helpers/govuk_design_system/components_helper.rb', line 8

def get_attribute_id_prefix(form, attribute)
  initial_name = form.object_name.present? ? "#{form.object_name}_#{attribute}" : attribute.to_s
  initial_name.gsub(/[\[\]_]+/, "_")
end

#get_attribute_name(form, attribute) ⇒ Object

Patterns for names and ids can be found in examples here: guides.rubyonrails.org/form_helpers.html



4
5
6
# File 'app/helpers/govuk_design_system/components_helper.rb', line 4

def get_attribute_name(form, attribute)
  form.object_name.present? ? "#{form.object_name}[#{attribute}]" : attribute.to_s
end