bootstrap_form icon indicating copy to clipboard operation
bootstrap_form copied to clipboard

Putting bootstrap_form specific options under :bootstrap key

Open GBH opened this issue 7 years ago • 1 comments
trafficstars

Right now form_for is being polluted with options like :layout, :label_col and friends. And all of those are getting passed in into super call. Not great.

Options for helpers are even worse. Here's a fun line:

check_box_options = options.except(:label, :label_class, :help, :inline, :custom)

Gotta remove our options not to poison html attributes on rendered fields.

This can be avoided if we introduce a wrapper for all our options. For example:

class BootstrapForm::FormBuilder
  def initialize(object_name, object, template, options)
    @bootstrap_options = options.delete(:bootstrap)
    super(object_name, object, template, options)
  end
end

Same idea for form helper methods. Clarifies what's bootstrap form specific and what's just your default options.

I wanted shorter :bs key, but maybe it's too much.

Thoughts?

GBH avatar Jan 18 '18 04:01 GBH

I like the idea of putting bootstrap_form-specific options under a :bootstrap key. This would be a breaking change, albeit with a fairly simple migration path. I'd like to consider this after we get the 4.0.0 alpha released.

mattbrictson avatar Jan 21 '18 19:01 mattbrictson