Class: Primrose::Components::Form

Inherits:
Rose
  • Object
show all
Defined in:
lib/primrose/components/form.rb

Constant Summary collapse

TEMPLATE =
<<~ERB
  <form class="<%= @style_class %>" action="<%= @action %>" method="<%= @method %>">
    <%= @elements.join("\n") %>
  </form>
ERB

Instance Attribute Summary

Attributes inherited from Rose

#children, #event_handlers, #state

Instance Method Summary collapse

Methods inherited from Rose

#add_child, #get_binding, #handle_error, #lifecycle, #on, #render_children, #trigger

Constructor Details

#initialize(elements:, method:, style_class: nil, action: nil, **opts) ⇒ Form

Returns a new instance of Form.



10
11
12
13
14
15
16
17
# File 'lib/primrose/components/form.rb', line 10

def initialize(elements:, method:, style_class: nil, action: nil, **opts)
  @elements = elements
  @options = opts
  @style_class = style_class
  @action = action
  @method = method
  super()
end

Instance Method Details

#render ⇒ Object



19
20
21
# File 'lib/primrose/components/form.rb', line 19

def render
  Prim.render(TEMPLATE, self)
end