os_form


A fill-in form to collect user input.

An os_form is a collection of elements that include input elements, selection elements, and block-structuring elements used for collecting information from users. Following is a list of input and selection elements that can be included on the form.

Each input element within an os_form is identified by a name. Input element names are not required to be unique. When an os_form is submitted, the name of each input element is paired with the current value of the input element (its content) and transmitted. An input element with a null value (an empty os_input_text or an unselected os_input_checkbox ) may not be transmitted by the browser.

An os_form must specify where to send the element data in the form of an action URL. When the form is submitted, information entered on a form is transmitted according to the specified action.

An os_form that specifies an HTTP URL can also specify the HTTP method to send the form data to the server. The submit method can either be post or get . By default, os_form data is sent using the post method. This is also the recommended method.

The action and submit methods are specified in the constructor and can be modified through the action() and method() member functions.

An os_form that specifies an HTTP action URL and the post submit method can specify the MIME type used to encode the form data through the encode() member function. Browsers default to the MIME type application/x-www-form-urlencoded , which at present is the only generally supported MIME type.

Elements are inserted into an os_form through either the add() member function or operator<< .

Note that os_form objects cannot be nested.

Declaration

#include <ospace/web/form.h>
class os_form : public os_element_group

Enums

enum os_form::submit_method
  {
  post,  // Submits form data using the HTTP post method.
  get    // Submits form data using the HTTP get method.
  };
	

Interface

Constructor
os_form( const string& action , submit_method method )
Constructs a form with action action and submit method method (default post ).
action
os_form& action ( const string& action )
Sets the action URL to action and returns a reference to the form.
action
string action() const
Returns the action URL.
clone
/* virtual */ os_element* clone() const
Returns a base class pointer to a heap-based deep copy of the form.
encode
os_form& encode( const string& encode )
Sets the MIME encoding type to encode and returns a reference to the form.
encode
string encode() const
Returns the MIME encoding type, or the empty string if not set.
method
os_form& method( submit_method method )
Sets the data submission method to method and returns a reference to the form.
method
int method() const
Returns the data submission method.
print
/* virtual */ void print( ostream& os ) const
Prints the form to os .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved