Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config.wrappers :inline_checkbox, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
- b.use :html5
- b.wrapper :tag => 'div', :class => 'controls' do |ba|
- ba.use :label_input, :wrap_with => { :class => 'checkbox inline' }
- ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
- end
- end
- config.wrappers :inline_checkbox_two, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
- b.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
- # everything else should use the same definition as the above
- end
- module WrapperHelper
- # options:
- # - wrapper [Hash]
- # - label_input [Hash]
- # - error [Hash]
- def self.inline_input(b, **kwargs)
- wrapper_opts = {
- tag: 'div',
- class: 'control-group'
- error_class: 'error'
- }.merge(kwargs[:wrapper] || {}) # merge defaults with passed `wrapper` keyword argument
- b.wrapper(wrapper_opts) do |ba|
- ba.use :label_input,
- { wrap_with: { class: 'checkbox inline' } }.merge(kwargs[:label_input] || {})
- ba.use :error,
- { wrap_with: { tag: 'span', class: 'help-inline' } }.merge(kwargs[:error] || {})
- end
- end
- end
- config.wrappers :html5_inline_checkbox do |b|
- config.use :html5
- WrapperHelper.inline_input(b)
- end
- config.wrappers :inline_checkbox_with_helpers do |b|
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
- WrapperHelper.inline_input(b)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement