class UiBibz::Ui::Core::Forms::Choices::BoxSwitchField
Create a SurroundField
This element is an extend of UiBibz::Ui::Core::Component
. Source : www.bootstrap-switch.org/documentation-2.html
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
state
- Symbol (:active
,:disabled
) -
inline
- Boolean -
animate
- Boolean -
on_color
- String -
off_color
- String -
on_text
- String -
off_text
- String -
label_text
- String -
readonly
- Boolean -
checked
- Boolean
Signatures¶ ↑
UiBibz::Ui::Core::Forms::BoxSwitchField.new(content, options = {}, html_options = {}).render UiBibz::Ui::Core::Forms::BoxSwitchField.new(options = {}, html_options = {}) do content end.render
Examples¶ ↑
box_switch_field 'name', { on_color: :primary }, { readonly: true }
Helper¶ ↑
box_switch_field(options = {}, html_options = {}) do # content end
Public Instance Methods
Render html tag
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 52 def pre_render box_switch_field_html_tag end
Private Instance Methods
true, false => default : true
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 99 def animate add_html_data('animate', value: options.delete(:animate)) unless options[:animate].nil? end
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 58 def box_switch_field_html_tag content_tag :div, class: component_wrapper_html_classes do concat hidden_field_tag content, '0' concat check_box_tag content, '1', html_options[:checked], html_options end end
UiBibz::Ui::Core::Component#component_html_classes
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 73 def component_html_classes super << 'switch-field' end
UiBibz::Ui::Core::Component#component_html_data
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 77 def component_html_data super size state animate left_color right_color left_text right_text middle_text end
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 69 def component_wrapper_html_classes join_classes('switch-field-container', inline) end
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 133 def inline 'btn-group' unless options[:inline].nil? end
'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 109 def left_color add_html_data('on_color', value: options[:left_color]) unless options[:left_color].nil? end
String => default : “ON”
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 119 def left_text add_html_data('on_text', value: options[:left_text]) unless options[:left_text].nil? end
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 94 def matching_size { sm: 'small', md: 'normal', lg: 'large' } end
String => default : ' '
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 129 def middle_text add_html_data('label_text', value: options[:middle_text]) unless options[:middle_text].nil? end
'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 114 def right_color add_html_data('off_color', value: options[:right_color]) unless options[:right_color].nil? end
String => default : “OFF”
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 124 def right_text add_html_data('off_text', value: options[:right_text]) unless options[:right_text].nil? end
'', 'mini', 'small', 'normal', 'large'
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 90 def size add_html_data('size', value: matching_size[options[:size]]) unless options[:size].nil? end
active, disabled => default : active
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 104 def state html_options[:disabled] = true if options[:state] == 'disabled' end
# File lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb, line 65 def value options[:value] end