add SimpleForm.default_wrapper
This commit is contained in:
parent
bcc4f1eada
commit
e506e60f6a
|
@ -49,6 +49,8 @@ SimpleForm.setup do |config|
|
|||
# Check the Bootstrap docs (http://twitter.github.com/bootstrap)
|
||||
# to learn about the different styles for forms and inputs,
|
||||
# buttons and other elements.
|
||||
config.default_wrapper :bootstrap
|
||||
|
||||
config.wrappers :bootstrap, :tag => 'fieldset', :class => 'control-group', :error_class => 'error' do |b|
|
||||
b.use :placeholder
|
||||
b.use :label, :class => 'control-label'
|
||||
|
|
|
@ -113,6 +113,9 @@ module SimpleForm
|
|||
@@button_class = 'button'
|
||||
|
||||
## WRAPPER CONFIGURATION
|
||||
# The default wrapper to be used by the FormBuilder.
|
||||
mattr_accessor :default_wrapper
|
||||
@@default_wrapper = :default
|
||||
@@wrappers = {}
|
||||
|
||||
# Retrieves a given wrapper
|
||||
|
|
|
@ -32,7 +32,7 @@ module SimpleForm
|
|||
def initialize(*) #:nodoc:
|
||||
super
|
||||
@defaults = options[:defaults]
|
||||
@wrapper = SimpleForm.wrapper(options[:wrapper] || :default)
|
||||
@wrapper = SimpleForm.wrapper(options[:wrapper] || SimpleForm.default_wrapper)
|
||||
end
|
||||
|
||||
# Basic input helper, combines all components in the stack to generate
|
||||
|
|
|
@ -17,7 +17,7 @@ class SimpleFormGeneratorTest < Rails::Generators::TestCase
|
|||
|
||||
test 'generates the simple_form initializer with the bootstrap wrappers' do
|
||||
run_generator %w(--bootstrap)
|
||||
assert_file 'config/initializers/simple_form.rb', /config\.wrappers :bootstrap/
|
||||
assert_file 'config/initializers/simple_form.rb', /config\.wrappers :bootstrap/, /config\.default_wrapper :bootstrap/
|
||||
end
|
||||
|
||||
%W(erb haml slim).each do |engine|
|
||||
|
|
Loading…
Reference in New Issue