Class: Shoelace::SlFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Shoelace::SlFormBuilder
- Defined in:
- app/helpers/shoelace/sl_form_builder.rb
Overview
:nodoc:
Instance Method Summary collapse
- #check_box(method, options = {}, checked_value = "1", unchecked_value = "0", &block) ⇒ Object
- #collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
- #collection_select(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
- #color_field(method, **options) ⇒ Object (also: #color_picker)
- #grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}, &block) ⇒ Object
- #range_field(method, **options) ⇒ Object (also: #range)
- #select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
- #switch_field(method, **options, &block) ⇒ Object (also: #switch)
- #text_area(method, **options, &block) ⇒ Object
Instance Method Details
#check_box(method, options = {}, checked_value = "1", unchecked_value = "0", &block) ⇒ Object
68 69 70 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 68 def check_box(method, = {}, checked_value = "1", unchecked_value = "0", &block) Components::SlCheckbox.new(object_name, method, @template, checked_value, unchecked_value, .with_defaults(label: label_text(method)).merge(object: @object)).render(&block) end |
#collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
87 88 89 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 87 def (method, collection, value_method, text_method, = {}, = {}, &block) Components::SlCollectionRadioButtons.new(object_name, method, @template, collection, value_method, text_method, .with_defaults(object: @object, label: label_text(method)), ).render(&block) end |
#collection_select(method, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ Object
77 78 79 80 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 77 def collection_select(method, collection, value_method, text_method, = {}, = {}, &block) slot = wrap_with_default_slot(method, &block) Components::SlCollectionSelect.new(object_name, method, @template, collection, value_method, text_method, .with_defaults(object: @object), .with_defaults(label: label_text(method)), slot).render end |
#color_field(method, **options) ⇒ Object Also known as: color_picker
45 46 47 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 45 def color_field(method, **) Components::SlColorPicker.new(object_name, method, @template, .with_defaults(object: @object, label: label_text(method))).render end |
#grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}, &block) ⇒ Object
82 83 84 85 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 82 def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, = {}, = {}, &block) slot = wrap_with_default_slot(method, &block) Components::SlGroupedCollectionSelect.new(object_name, method, @template, collection, group_method, group_label_method, option_key_method, option_value_method, .with_defaults(object: @object), .with_defaults(label: label_text(method)), slot).render end |
#range_field(method, **options) ⇒ Object Also known as: range
50 51 52 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 50 def range_field(method, **) Components::SlRange.new(object_name, method, @template, .with_defaults(object: @object, label: label_text(method))).render end |
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
72 73 74 75 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 72 def select(method, choices = nil, = {}, = {}, &block) slot = wrap_with_default_slot(method, &block) Components::SlSelect.new(object_name, method, @template, choices, .with_defaults(object: @object), .with_defaults(label: label_text(method)), slot).render end |
#submit(value = nil, options = {}) ⇒ Object
91 92 93 94 95 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 91 def submit(value = nil, = {}) value, = nil, value if value.is_a?(Hash) @template.sl_submit_tag(value || submit_default_value, **) end |
#switch_field(method, **options, &block) ⇒ Object Also known as: switch
55 56 57 58 59 60 61 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 55 def switch_field(method, **, &block) if block_given? Components::SlSwitch.new(object_name, method, @template, .with_defaults(object: @object)).render(&block) else Components::SlSwitch.new(object_name, method, @template, .with_defaults(object: @object, label: label_text(method))).render(&block) end end |
#text_area(method, **options, &block) ⇒ Object
64 65 66 |
# File 'app/helpers/shoelace/sl_form_builder.rb', line 64 def text_area(method, **, &block) Components::SlTextarea.new(object_name, method, @template, .with_defaults(object: @object, label: label_text(method), resize: 'auto')).render(&block) end |