Class form

Description

Form class

A container object for form elements. This is for when we have a classical form which is just a set of form elements for filling in, rather than a mixture of page layout and elements. It is rendered in a vanilla table with each field stacked vertically to the right of its label..

Located in /form-defs.php (line 96)

RenderableObject
   |
   --StylableObject
      |
      --HTMLObject
         |
         --form
Direct descendents
Class Description
 class subform SubForm class The sub-form is a special case of the form class. The difference is that it is expected to be part of an existing form, and therefore is rendered without the form tags.
 class multipart_form multipart_form class The multipart_form is just a standard form, but with the enctype pre-set to the "multipart/form-data" setting required for file multiparts of binary form data.
Variable Summary
 mixed $action
 mixed $elements
 mixed $enctype
 mixed $labelcolon
 mixed $labelcss
 mixed $method
 mixed $onsubmit
 mixed $showlabels
 mixed $type
Method Summary
 form form ([string $name = ""], [string $title = ""], [string $action = ""], [string $method = "post"], [string $enctype = ""], [mixed $css = ""], [mixed $charsets = ""])
 void add (object $element)
 void add_annotation (string $text, [string $css = ""])
 void add_button (object $button)
 void add_fileuploadfields (object $element, [integer $count = 1], [boolean $labels = false])
 void add_separator ([string $heading = ""], [string $css = ""])
 void add_text (string $text, [string $css = ""])
 void force_readonly ([mixed $mode = true])
 string html ()
 void set_fieldwidth_pct ([integer $pctwidth = 65])
 void set_onsubmit (string $script)
 void set_type ([string $type = "normal"])
Variables
mixed $accept_charsets = "" (line 105)

Accept-charset attributes - comma-delimited list

mixed $action = "" (line 99)

Action attribute

mixed $elements (line 126)

Elements array. Contains form elements

mixed $elewidth_pct = 65 (line 117)

Width taken by element (RHS) side of the form in %

mixed $enctype = "" (line 103)

Encoding type

mixed $force_readonly = false (line 119)

Whether to force forma elements to be read-only

mixed $labelcolon = true (line 113)

Whether to append colon ":" to labels

mixed $labelcss (line 115)

Optional class/style for labels

mixed $labeljustify = "right" (line 111)

Justification mode for labels "right" or "left"

mixed $method = "post" (line 101)

Method attribute

mixed $onsubmit (line 107)

Script to call on form submit

mixed $showlabels = true (line 109)

Whether to render labels for fields

mixed $type = "normal" (line 123)

Type of form 'normal' or 'subform'

Inherited Variables

Inherited from HTMLObject

HTMLObject::$accesskey
HTMLObject::$align
HTMLObject::$alt
HTMLObject::$bgcolor
HTMLObject::$bgurl
HTMLObject::$border
HTMLObject::$color
HTMLObject::$height
HTMLObject::$hspace
HTMLObject::$lang
HTMLObject::$langdir
HTMLObject::$linkover_text
HTMLObject::$name
HTMLObject::$onblur
HTMLObject::$onchange
HTMLObject::$onclick
HTMLObject::$ondblclick
HTMLObject::$onfocus
HTMLObject::$onkeydown
HTMLObject::$onkeypress
HTMLObject::$onkeyup
HTMLObject::$onload
HTMLObject::$onmousedown
HTMLObject::$onmousemove
HTMLObject::$onmouseout
HTMLObject::$onmouseover
HTMLObject::$onmouseup
HTMLObject::$onselect
HTMLObject::$size
HTMLObject::$src
HTMLObject::$tabindex
HTMLObject::$target
HTMLObject::$title
HTMLObject::$user_attributes
HTMLObject::$valign
HTMLObject::$vspace
HTMLObject::$width

Inherited from StylableObject

StylableObject::$class
StylableObject::$id
StylableObject::$style
Methods
Constructor form (line 137)

Constructor Create a form object. Sets basic form attributes.

form form ([string $name = ""], [string $title = ""], [string $action = ""], [string $method = "post"], [string $enctype = ""], [mixed $css = ""], [mixed $charsets = ""])
  • string $name: The name of the form
  • string $title: The title/banner for the form
  • string $action: Action attribute, ie. the script to POST to
  • string $method: Method attribute, POST or GET
  • string $enctype: Encoding type
add (line 175)

Adds a form element object to the form. This is usually an object you have previously created eg. with new form_textfield(...) etc.

void add (object $element)
  • object $element: The form element object to add
add_annotation (line 215)

Add annotation to the form Adds text content to the form in the field column. The text is added literally, so you can add in effects like <em>..</em> etc.

void add_annotation (string $text, [string $css = ""])
  • string $text: Text to display in the form
  • string $css: Style/class to apply (NB: not rendered at present)
add_button (line 268)

Add a button Adds a button element to the form.

void add_button (object $button)
  • object $button: The button element object to add
add_fileuploadfields (line 229)

Add file upload fields Special function to add repeated fileupload fields to the form.

These share the same naming, but with square brackets "[]" appended.

void add_fileuploadfields (object $element, [integer $count = 1], [boolean $labels = false])
  • object $element: The form element object to add
  • integer $count: The number of elements to add
  • boolean $labels: Whether we have individual field labels
add_separator (line 189)

Add form separator row

Adds a separator row to the form If no heading is given then this produces a ruled line across the form. If a heading is given then this text is put in a row just below the ruled line. Feel free to add in HTML formatting using normal HTML tags like etc.

void add_separator ([string $heading = ""], [string $css = ""])
  • string $heading: Optional separator title/heading text
  • string $css: Style/class to apply (not rendered at present)
add_text (line 202)

Add text to the form Adds text content to the form spanning both columns. The text is added literally, so you can add in effects like <em>..</em> etc.

void add_text (string $text, [string $css = ""])
  • string $text: Text to display in the form
  • string $css: Style/class to apply (NB: not rendered at present)
contains_fileuploadfield (line 299)

Check if form contains file upload field Check all elements for presence of file upload field. This is mainly for internal use.

  • return: True if form contains a file upload field
boolean contains_fileuploadfield ()
force_readonly (line 166)

Force all of the contained fields to be rendered read-only

void force_readonly ([mixed $mode = true])
html (line 317)

This renders the form as HTML, including the form tags and every form element in the form.

  • return: The form as HTML.
string html ()

Redefinition of:
RenderableObject::html()
Return output suitable for normal HTML-capable device. This method must be over-ridden by a method of the same name in the descendant class which renders output to web browsers.
set_fieldwidth_pct (line 161)

Set the proportion of the form taken up by the form field elements as opposed to the labels. This is specified as an integer which is the proportion as a percentage. Eg: 70 would be '70%'.

void set_fieldwidth_pct ([integer $pctwidth = 65])
  • integer $pctwidth: Percentage width of form for form fields
set_onsubmit (line 278)

Set onsubmit script Defines the onsubmit script to call when the user submits the form.

void set_onsubmit (string $script)
  • string $script: The script to execute on form submit
set_type (line 289)

Set the form type This can be 'normal' or 'subform'. Use the subform variant when you already have <form> tags being provided by other means. Then when you render the subform only the fields will be returned.

void set_type ([string $type = "normal"])
  • string $type: The form type 'normal' or 'subform'

Inherited Methods

Inherited From HTMLObject

 HTMLObject::HTMLObject()
 HTMLObject::inherit_attributes()
 HTMLObject::setaccesskey()
 HTMLObject::setalign()
 HTMLObject::setalt()
 HTMLObject::setbackground()
 HTMLObject::setbgcolor()
 HTMLObject::setborder()
 HTMLObject::setcolor()
 HTMLObject::setheight()
 HTMLObject::sethspace()
 HTMLObject::setlang()
 HTMLObject::setlangdir()
 HTMLObject::setname()
 HTMLObject::setsize()
 HTMLObject::setsrc()
 HTMLObject::settabindex()
 HTMLObject::settarget()
 HTMLObject::settitle()
 HTMLObject::setvalign()
 HTMLObject::setvspace()
 HTMLObject::setwidth()
 HTMLObject::set_attribute()
 HTMLObject::set_linkover_text()
 HTMLObject::set_onblur()
 HTMLObject::set_onchange()
 HTMLObject::set_onclick()
 HTMLObject::set_ondblclick()
 HTMLObject::set_onfocus()
 HTMLObject::set_onkeydown()
 HTMLObject::set_onkeypress()
 HTMLObject::set_onkeyup()
 HTMLObject::set_onload()
 HTMLObject::set_onmousedown()
 HTMLObject::set_onmousemove()
 HTMLObject::set_onmouseout()
 HTMLObject::set_onmouseover()
 HTMLObject::set_onmouseup()
 HTMLObject::set_onselect()
 HTMLObject::set_tabindex()
 HTMLObject::taghtml()

Inherited From StylableObject

 StylableObject::StylableObject()
 StylableObject::clearstyle()
 StylableObject::setclass()
 StylableObject::setcss()
 StylableObject::setid()
 StylableObject::setstyle()

Inherited From RenderableObject

 RenderableObject::RenderableObject()
 RenderableObject::html()
 RenderableObject::render()
 RenderableObject::wml()
 RenderableObject::wmlup()
 RenderableObject::xml()

Documentation generated by phpDocumentor 1.3.0RC3