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
-
#initialize(id, value = nil) ⇒ Form
constructor
A new instance of Form.
- #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, label, listview, panel, password_textfield, #render_container, textarea, textfield
Methods inherited from Component
#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage
Constructor Details
#initialize(id, value = nil) ⇒ Form
Returns a new instance of Form.
120 121 122 |
# File 'lib/lapillus/containers.rb', line 120 def initialize(id, value=nil) super(id, value) end |
Instance Method Details
#on_submit(button = nil) ⇒ Object
126 127 128 |
# File 'lib/lapillus/containers.rb', line 126 def on_submit(=nil) instance_eval(&@function) end |
#on_submit_handler=(function) ⇒ Object
123 124 125 |
# File 'lib/lapillus/containers.rb', line 123 def on_submit_handler=function @function=function end |
#post(values) ⇒ Object
137 138 139 140 141 142 |
# File 'lib/lapillus/containers.rb', line 137 def post(values) components.each {|component| component.post(values)} if values.keys.find {|key| key.include?(identifier)} on_submit(values['submit'].nil? ? nil : values['submit'].string) end end |
#render_to_element(element) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/lapillus/containers.rb', line 129 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 |