Class: SWS::Form
- Defined in:
- lib/sws/Core/components/Form/Form.rb
Overview
Represents <FORM> tag. Bindings:
-
method (default: “POST”) - HTTP methods to send form data
-
enctype - as “enctype” parameter of HTML form
-
other_tag_string - generic string to add to the FORM tag
-
action - method to call on form submission (you shouldn’t use both Form’s
and SubmitButton’s action at the same time)
Instance Attribute Summary
Attributes inherited from Component
#action_components, #definition_component, #encoding, #html_attrs, #method_to_call, #name, #parameters, #parent, #request, #request_number, #slots, #subcomponents, #tokens
Instance Method Summary collapse
-
#enable_action ⇒ Object
Enables the action of the receiver, so that the action will be performed.
-
#generate_footer ⇒ Object
Generates closing </FORM> tag.
-
#generate_head ⇒ Object
Generates opening <FORM> tag with proper attributes.
-
#initialize(*args) ⇒ Form
constructor
A new instance of Form.
-
#perform_action ⇒ Object
Performs the action if it has been set up.
Methods inherited from Component
#api_filename, #app, #append_to_response, #awake, #container?, #content?, create, #create_component_tree, #definition_filename, #page, #process_bindings, #process_parameters, #process_request, #remove_subcomponents, #session, #set_request_subcomponents, #sleep, #slot_bound?, #subcomponent_for_name, synchronize_slot, #synchronize_slot?, #synchronize_slots, #template_filename, #tokenize_binding, #update_binding, #url_string
Constructor Details
#initialize(*args) ⇒ Form
Returns a new instance of Form.
12 13 14 15 |
# File 'lib/sws/Core/components/Form/Form.rb', line 12 def initialize (*args) super @action = nil end |
Instance Method Details
#enable_action ⇒ Object
Enables the action of the receiver, so that the action will be performed. Called by request handler, when it finds this form id in url
43 44 45 |
# File 'lib/sws/Core/components/Form/Form.rb', line 43 def enable_action () @action = @slots["action"].bound_object() end |
#generate_footer ⇒ Object
Generates closing </FORM> tag
37 38 39 |
# File 'lib/sws/Core/components/Form/Form.rb', line 37 def () return "</FORM>" end |
#generate_head ⇒ Object
Generates opening <FORM> tag with proper attributes. Do NOT use other methods than default POST
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sws/Core/components/Form/Form.rb', line 19 def generate_head () string = "<FORM" string << " #{@slots["method"].to_tag_attribute()}" string << " action=\"#{app.adaptor.base_path}#{app.component_request_handler_key}/#{page.url_string}" if (slot_bound?( "action" )) page.action_components[ self.object_id ] = self string << "/#{self.object_id}" end string << "\" #{@slots["enctype"].to_tag_attribute()}" string << generic_attr_string() string << ">" return string end |
#perform_action ⇒ Object
Performs the action if it has been set up
49 50 51 |
# File 'lib/sws/Core/components/Form/Form.rb', line 49 def perform_action () return @action ? @action.call() : super; end |