Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom_control #289

Merged
merged 3 commits into from
Jan 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/bootstrap_form/helpers/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ def static_control(*args, &block)
end
end

def custom_control(*args, &block)
options = args.extract_options!
name = args.first

form_group_builder(name, options) do
capture(&block)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this accomplish the same thing? Do we need the extract_options! and capture?

def custom_control(name, options={}, &block)
   form_group_builder(name, options, &block)
end

Copy link
Contributor Author

@ThomasSevestre ThomasSevestre Dec 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract_options! is not needed. I've copied static_control to have the same ergonomy. It allows this kind of things:

= custom_control label: 'MyLabel' do
  ...

capture is not needed since it is already done in form_group

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see... So in order to support the example you described (custom_control label: 'MyLabel'), then we do need extract_options!. Right?

capture is not needed since it is already done in form_group

Agreed. Can you update the PR to remove it?


def prepend_and_append_input(options, &block)
options = options.extract!(:prepend, :append, :input_group_class)
input_group_class = ["input-group", options[:input_group_class]].compact.join(' ')
Expand Down