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

Allow styling SELECT elements #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
7 changes: 5 additions & 2 deletions lib/twitter_bootstrap_form_for/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def inline(label = nil, &block)
INPUTS.each do |input|
define_method input do |attribute, *args, &block|
options = args.extract_options!
html_options = options.delete(:html)
label = args.first.nil? ? '' : args.shift
classes = [ 'controls', 'input' ]
classes << ('input-' + options.delete(:add_on).to_s) if options[:add_on]
Expand All @@ -95,7 +96,9 @@ def inline(label = nil, &block)
template.concat self.label(attribute, label) if label
template.concat template.content_tag(:div, :class => classes.join(' ')) {
block.call if block.present? and classes.include?('input-prepend')
template.concat super(attribute, *(args << options))
final_args = args << options
final_args << html_options if html_options
template.concat super(attribute, *final_args)
template.concat error_span(attribute)
block.call if block.present? and classes.include?('input-append')
}
Expand All @@ -107,7 +110,7 @@ def inline(label = nil, &block)
define_method toggle do |attribute, *args, &block|
label = args.first.nil? ? '' : args.shift
target = self.object_name.to_s + '_' + attribute.to_s
label_attrs = toggle == :check_box ? { :for => target } : {}
label_attrs = toggle == :check_box ? { :for => target, :class => "checkbox" } : { :class => "radio" }

template.content_tag(:li) do
template.concat template.content_tag(:label, label_attrs) {
Expand Down