team-formalist / formalist-rb

Flexible form builder
MIT License
22 stars 4 forks source link

Fix crash when errors are on `attr` keys? #80

Open timriley opened 5 years ago

timriley commented 5 years ago

See:

require "formalist"
require "formalist/elements/standard"

form = Class.new(Formalist::Form) do
  define do
    attr :itunes_image_attachment do
      text_field :asset_id
    end
  end
end.new

input = {"itunes_image_attachment"=>{"asset_id"=>""}}
errors = {itunes_image_attachment: ["must be filled"]}

form = form.fill(input: input, errors: errors)
# TypeError: no implicit conversion of Symbol into Integer
# from /Users/tim/Source/icelab/formalist/lib/formalist/elements/field.rb:16:in `fill'