Class: Lapillus::Form
- Defined in:
- lib/lapillus/containers.rb
Instance Attribute Summary
Attributes inherited from Container
Attributes inherited from Component
#behaviours, #identifier, #model, #property, #visible
Instance Method Summary collapse
- #on_submit(button = nil) ⇒ Object
- #on_submit_handler=(function) ⇒ Object
- #post(values) ⇒ Object
- #render_to_element(element) ⇒ Object
Methods inherited from Container
#[], #add, add_component, #component, fileuploadfield, image, #initialize, label, listview, panel, password_textfield, #render_children, textarea, textfield
Methods inherited from Component
#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #initialize, #parent, #path, #response_page=, #session, #value, #webpage
Methods inherited from RenderableComponent
#initialize, #on_render, #render_behaviours, #render_children, #render_component, #render_container, #visible?
Constructor Details
This class inherits a constructor from Lapillus::Container
Instance Method Details
#on_submit(button = nil) ⇒ Object
119 120 121 |
# File 'lib/lapillus/containers.rb', line 119 def on_submit(=nil) instance_eval(&@function) end |
#on_submit_handler=(function) ⇒ Object
116 117 118 |
# File 'lib/lapillus/containers.rb', line 116 def on_submit_handler=function @function=function end |
#post(values) ⇒ Object
130 131 132 133 134 135 |
# File 'lib/lapillus/containers.rb', line 130 def post(values) components.each {|component| component.post(values)} if values.keys.find {|key| key.include?(identifier.to_s)} on_submit(values['submit'].nil? ? nil : values['submit'].string) end end |
#render_to_element(element) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/lapillus/containers.rb', line 122 def render_to_element(element) element.add_attribute("method", "post") element.attributes['enctype'] = 'multipart/form-data' input = element.add_element("input") input.attributes['type'] = 'hidden' input.attributes['name'] = 'page' input.attributes['value'] = webpage.class.to_s end |