trailblazer / formular

Form builder for Ruby. Fast, Furious, and Framework-Agnostic.
MIT License
81 stars 17 forks source link

When using Formular outside any template environment, it renders collection twice #3

Open blelump opened 8 years ago

blelump commented 8 years ago

Consider such example:

class CustomBuilder < Formular::Builders::Bootstrap3
end

model = OpenStruct.new(ble: "blargh", coll: [OpenStruct.new(name: 1, id: 3), OpenStruct.new(name: 2, id: 5)])

f = CustomBuilder.new(model: model, path_prefix: "blah" ).form(method: :post, action: "/ok") do |f|
  concat f.input :ble
  f.collection :coll do |g|
    concat g.input :name
    concat g.input :id
  end
end

The result is: img

fran-worley commented 8 years ago

Thanks for reporting, I've added a failing test to this branch and have got a fix for use without template engines, but it breaks ERB... So still a work in progress here I'm afraid!

https://github.com/trailblazer/formular/blob/fix-collection-buffer/lib/formular/builder.rb#L48-L49