[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Form/ -> Form.php (summary)

(no description)

File Size: 462 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Form:: (28 methods):
  __construct()
  setHiddenField()
  elementCount()
  getElementPosition()
  getElementAt()
  findPositionByType()
  findPositionByAttribute()
  addElement()
  replaceElement()
  removeElement()
  addTextInput()
  addPasswordInput()
  addRadioButton()
  addCheckbox()
  addDropdown()
  addTextarea()
  addButton()
  addButtonHTML()
  addLabel()
  addLabelHTML()
  addHTML()
  addTag()
  addTagOpen()
  addTagClose()
  addFieldsetOpen()
  addFieldsetClose()
  balanceFieldsets()
  toHTML()


Class: Form  - X-Ref

Class Form

Represents the whole Form. This is what you work on, and add Elements to

__construct($attributes = array()   X-Ref
Creates a new, empty form with some default attributes

param: array $attributes
param: bool  $unsafe     if true, then the security token is ommited

setHiddenField($name, $value)   X-Ref
Sets a hidden field

param: string $name
param: string $value
return: $this

elementCount()   X-Ref
Returns the numbers of elements in the form

return: int

getElementPosition(Element $element)   X-Ref
Get the position of the element in the form or false if it is not in the form

Warning: This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates
to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the
return value of this function.

param: Element $element
return: false|int

getElementAt($pos)   X-Ref
Returns a reference to the element at a position.
A position out-of-bounds will return either the
first (underflow) or last (overflow) element.

param: int $pos
return: Element

findPositionByType($type, $offset = 0)   X-Ref
Gets the position of the first of a type of element

param: string $type Element type to look for.
param: int $offset search from this position onward
return: false|int position of element if found, otherwise false

findPositionByAttribute($name, $value, $offset = 0)   X-Ref
Gets the position of the first element matching the attribute

param: string $name Name of the attribute
param: string $value Value the attribute should have
param: int $offset search from this position onward
return: false|int position of element if found, otherwise false

addElement(Element $element, $pos = -1)   X-Ref
Adds or inserts an element to the form

param: Element $element
param: int $pos 0-based position in the form, -1 for at the end
return: Element

replaceElement(Element $element, $pos)   X-Ref
Replaces an existing element with a new one

param: Element $element the new element
param: int $pos 0-based position of the element to replace

removeElement($pos)   X-Ref
Remove an element from the form completely

param: int $pos 0-based position of the element to remove

addTextInput($name, $label = '', $pos = -1)   X-Ref
Adds a text input field

param: string $name
param: string $label
param: int $pos
return: InputElement

addPasswordInput($name, $label = '', $pos = -1)   X-Ref
Adds a password input field

param: string $name
param: string $label
param: int $pos
return: InputElement

addRadioButton($name, $label = '', $pos = -1)   X-Ref
Adds a radio button field

param: string $name
param: string $label
param: int $pos
return: CheckableElement

addCheckbox($name, $label = '', $pos = -1)   X-Ref
Adds a checkbox field

param: string $name
param: string $label
param: int $pos
return: CheckableElement

addDropdown($name, $options, $label = '', $pos = -1)   X-Ref
Adds a dropdown field

param: string $name
param: array $options
param: string $label
param: int $pos
return: DropdownElement

addTextarea($name, $label = '', $pos = -1)   X-Ref
Adds a textarea field

param: string $name
param: string $label
param: int $pos
return: TextareaElement

addButton($name, $content, $pos = -1)   X-Ref
Adds a simple button, escapes the content for you

param: string $name
param: string $content
param: int $pos
return: Element

addButtonHTML($name, $html, $pos = -1)   X-Ref
Adds a simple button, allows HTML for content

param: string $name
param: string $html
param: int $pos
return: Element

addLabel($label, $for='', $pos = -1)   X-Ref
Adds a label referencing another input element, escapes the label for you

param: string $label
param: string $for
param: int $pos
return: Element

addLabelHTML($content, $for='', $pos = -1)   X-Ref
Adds a label referencing another input element, allows HTML for content

param: string $content
param: string|Element $for
param: int $pos
return: Element

addHTML($html, $pos = -1)   X-Ref
Add fixed HTML to the form

param: string $html
param: int $pos
return: HTMLElement

addTag($tag, $pos = -1)   X-Ref
Add a closed HTML tag to the form

param: string $tag
param: int $pos
return: TagElement

addTagOpen($tag, $pos = -1)   X-Ref
Add an open HTML tag to the form

Be sure to close it again!

param: string $tag
param: int $pos
return: TagOpenElement

addTagClose($tag, $pos = -1)   X-Ref
Add a closing HTML tag to the form

Be sure it had been opened before

param: string $tag
param: int $pos
return: TagCloseElement

addFieldsetOpen($legend = '', $pos = -1)   X-Ref
Open a Fieldset

param: string $legend
param: int $pos
return: FieldsetOpenElement

addFieldsetClose($pos = -1)   X-Ref
Close a fieldset

param: int $pos
return: TagCloseElement

balanceFieldsets()   X-Ref
Adjust the elements so that fieldset open and closes are matching


toHTML()   X-Ref
The HTML representation of the whole form

return: string