trailblazer / formular

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

Question regarding builder #47

Closed joep closed 7 years ago

joep commented 7 years ago

Ideally, I'd like to add some of my own elements to an existing builder. The approach that seemed most obvious to me doesn't appear to work, e.g.,

require 'formular/builders/bootstrap3'
class MyBuilder < Formular::Builders::Bootstrap3
  element_set(
    # my additional elements here
  )
end
Formular::Helper.builder = MyBuilder

As some point, it always tries to load 'formular/builders/MyBuilder'

So the question is, what is the best approach to use?

Thanks!

fran-worley commented 7 years ago

@joep up until just now the helper only worked with built in Builders.

Fancy giving it a go now (from master obvs)?

joep commented 7 years ago

Sure, appears to be simple enough if this looks like the right approach to you.

joep commented 7 years ago

Uh, it actually looks like this was done in the last commit?

fran-worley commented 7 years ago

yeah, you should be good to go :)

fran-worley commented 7 years ago

If you need elements for a specific form, you can also add pass them into your form call as an option e.g. form(model, url, elements: {super_special_label: MyLabel})

Elements here will be merged with those of the builder being used.

joep commented 7 years ago

Ah, ok. This is a pretty slick system you guys have, Formular + Reform. From start to finish, I managed to add a recaptcha element to the form, complete with validation by Reform in just a couple of hours, not including the first few hours of stumbling around with the documentation before realizing I needed to dig a little deeper into the code.

Thanks for your work!