Class: VCFB::Component::Form
Instance Method Summary collapse
-
#form_tag(options = {}, &block) ⇒ Object
Because we’ve overridden the #content and #get_slot methods below to support yielding the form, we need to save the component to our custom form builder to support rendering slots in the form components.
-
#initialize(model: nil, scope: nil, url: nil, format: nil, **options) ⇒ Form
constructor
A new instance of Form.
Methods inherited from Base
#collection_check_boxes, #collection_radio_buttons
Constructor Details
#initialize(model: nil, scope: nil, url: nil, format: nil, **options) ⇒ Form
Returns a new instance of Form.
4 5 6 7 8 9 10 11 12 |
# File 'lib/vcfb/component/form.rb', line 4 def initialize(model: nil, scope: nil, url: nil, format: nil, **) run_callbacks :initialize do @model = model @scope = scope @url = url @format = format @options = defined?(TagOptions::Hash) ? TagOptions::Hash.new() : end end |
Instance Method Details
#form_tag(options = {}, &block) ⇒ Object
Because we’ve overridden the #content and #get_slot methods below to support yielding the form, we need to save the component to our custom form builder to support rendering slots in the form components.
17 18 19 20 21 22 23 |
# File 'lib/vcfb/component/form.rb', line 17 def form_tag( = {}, &block) form_with(model: @model, scope: @scope, url: @url, format: @format, **) do |form| form.form_component = self if form.respond_to?(:form_component=) @form = form block&.call(@form) end end |