Class: Koi::Content::Editor::ItemFormComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
Katalyst::HtmlAttributes
Defined in:
app/components/koi/content/editor/item_form_component.rb

Defined Under Namespace

Modules: ContentFormHelper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, url:, builder: Koi::FormBuilder) ⇒ ItemFormComponent

Returns a new instance of ItemFormComponent.



11
12
13
14
15
16
17
# File 'app/components/koi/content/editor/item_form_component.rb', line 11

def initialize(model:, url:, builder: Koi::FormBuilder, **)
  super(**)

  @model   = model
  @url     = url
  @builder = builder
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



9
10
11
# File 'app/components/koi/content/editor/item_form_component.rb', line 9

def builder
  @builder
end

#formObject (readonly)

Returns the value of attribute form.



9
10
11
# File 'app/components/koi/content/editor/item_form_component.rb', line 9

def form
  @form
end

#modelObject (readonly)

Returns the value of attribute model.



9
10
11
# File 'app/components/koi/content/editor/item_form_component.rb', line 9

def model
  @model
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'app/components/koi/content/editor/item_form_component.rb', line 9

def url
  @url
end

Instance Method Details

#contentObject



27
28
29
30
31
32
# File 'app/components/koi/content/editor/item_form_component.rb', line 27

def content
  @__vc_content_evaluated = true
  return @__vc_content if defined?(@__vc_content)

  @__vc_content = view_context.capture(@form, &@__vc_render_in_block)
end

#form_with(**options, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'app/components/koi/content/editor/item_form_component.rb', line 19

def form_with(**options, &block)
  view_context.form_with(**options) do |form|
    @form = form
    form.extend(ContentFormHelper)
    capture(form, &block)
  end
end

#inspectObject



34
35
36
# File 'app/components/koi/content/editor/item_form_component.rb', line 34

def inspect
  "#<#{self.class.name} model: #{model.inspect} url: #{url.inspect}>"
end