Class: NitroKit::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- NitroKit::FormBuilder
- Defined in:
- app/components/nitro_kit/form_builder.rb
Instance Method Summary collapse
- #button(value = "Save changes", **options) ⇒ Object
- #checkbox(method, options = {}) ⇒ Object (also: #check_box)
- #field(object_name, **options) ⇒ Object
- #field_group(options = {}, &block) ⇒ Object
-
#fieldset(options = {}, &block) ⇒ Object
Fields.
-
#label(object_name, method, content_or_options = nil, options = nil, &block) ⇒ Object
Inputs.
- #submit(value = "Save changes", **options) ⇒ Object
Instance Method Details
#button(value = "Save changes", **options) ⇒ Object
38 39 40 41 |
# File 'app/components/nitro_kit/form_builder.rb', line 38 def (value = "Save changes", **) content = value || @template.capture(&block) @template.render(NitroKit::Button.new(**)) { content } end |
#checkbox(method, options = {}) ⇒ Object Also known as: check_box
27 28 29 |
# File 'app/components/nitro_kit/form_builder.rb', line 27 def checkbox(method, = {}) @template.checkbox(@object_name, method, (), label: [:label]) end |
#field(object_name, **options) ⇒ Object
15 16 17 18 19 20 |
# File 'app/components/nitro_kit/form_builder.rb', line 15 def field(object_name, **) label = .fetch(:label, object_name.to_s.humanize) errors = object.errors.include?(object_name) ? object.errors.(object_name) : nil @template.render(NitroKit::Field.new(object_name, label:, errors:, **)) end |
#field_group(options = {}, &block) ⇒ Object
10 11 12 13 |
# File 'app/components/nitro_kit/form_builder.rb', line 10 def field_group( = {}, &block) content = @template.capture(&block) @template.render(NitroKit::FieldGroup.new(**)) { content } end |
#fieldset(options = {}, &block) ⇒ Object
Fields
5 6 7 8 |
# File 'app/components/nitro_kit/form_builder.rb', line 5 def fieldset( = {}, &block) content = @template.capture(&block) @template.render(NitroKit::Fieldset.new()) { content } end |
#label(object_name, method, content_or_options = nil, options = nil, &block) ⇒ Object
Inputs
24 25 |
# File 'app/components/nitro_kit/form_builder.rb', line 24 def label(object_name, method, = nil, = nil, &block) end |