[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

(no description)

File Size: 499 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 = [], $unsafe = false)   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

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

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.

return: false|int
param: Element $element

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.

return: Element
param: int $pos

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Be sure to close it again!

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

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

Be sure it had been opened before

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

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

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

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

return: TagCloseElement
param: int $pos

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


toHTML($eventName = null)   X-Ref
The HTML representation of the whole form

return: string
param: string $eventName  (optional) name of the event: FORM_{$name}_OUTPUT