ministryofjustice / govuk_elements_form_builder

Form builder helper methods to develop GOV.UK elements styled applications in Ruby on Rails
https://govuk-elements-rails-guide.herokuapp.com/
MIT License
6 stars 14 forks source link

Support for attribute names as a string #68

Open lostie opened 7 years ago

lostie commented 7 years ago

When trying to define a html tag for an attribute which is specified as a string, e.g.:

builder.text_area 'my_form_field'

The following error occurs:

     Failure/Error: output = builder.send method, 'name'
     NoMethodError:
       undefined method `find' for "name":String
     Shared Example Group: "input field" called from ./spec/lib/govuk_elements_form_builder/form_builder_spec.rb:272
     # ./lib/govuk_elements_form_builder/form_builder.rb:197:in `form_group_classes'
     # ./lib/govuk_elements_form_builder/form_builder.rb:29:in `block (2 levels) in <class:FormBuilder>'
     # ./spec/lib/govuk_elements_form_builder/form_builder_spec.rb:39:in `block (3 levels) in <top (required)>'

This is raised here as a ruby String also responds to the method :count and the conversion to array is not done appropriately.