dokeos
[ class tree: dokeos ] [ index: dokeos ] [ all elements ]

Class: FormValidator

Source Location: /main/inc/lib/formvalidator/FormValidator.class.php

Class Overview

HTML_Common
   |
   --HTML_QuickForm
      |
      --FormValidator

Objects of this class can be used to create/manipulate/validate user input.


Author(s):

Version:

  • 2.0

Variables

Methods


Child classes:

LinkAddEditForm
Form used to add or edit links
ScoreDisplayForm
Form for the score display dialog
LinkForm
Forms related to links
CatForm
Extends formvalidator with add&edit forms
DataForm
Extends formvalidator with import and export forms
UserForm
Extends formvalidator with import and export forms
EvalForm
Extends formvalidator with add&edit forms for evaluations

Inherited Variables

Inherited Methods

Class: HTML_QuickForm

HTML_QuickForm::HTML_QuickForm()
Class constructor
HTML_QuickForm::accept()
Accepts a renderer
HTML_QuickForm::addElement()
Adds an element into the form
HTML_QuickForm::addFormRule()
Adds a global validation rule
HTML_QuickForm::addGroup()
Adds an element group
HTML_QuickForm::addGroupRule()
Adds a validation rule for the given group of elements
HTML_QuickForm::addRule()
Adds a validation rule for the given field
HTML_QuickForm::apiVersion()
Returns the current API version
HTML_QuickForm::applyFilter()
Applies a data filter for the given field(s)
HTML_QuickForm::arrayMerge()
Merges two arrays
HTML_QuickForm::createElement()
Creates a new form element of the given type.
HTML_QuickForm::defaultRenderer()
Returns a reference to default renderer object
HTML_QuickForm::elementExists()
Returns true if element is in the form
HTML_QuickForm::errorMessage()
Return a textual error message for an QuickForm error code
HTML_QuickForm::exportValue()
Returns a 'safe' element's value
HTML_QuickForm::exportValues()
Returns 'safe' elements' values
HTML_QuickForm::freeze()
Displays elements without HTML input tags
HTML_QuickForm::getElement()
Returns a reference to the element
HTML_QuickForm::getElementError()
Returns error corresponding to validated element
HTML_QuickForm::getElementType()
Returns the type of the given element
HTML_QuickForm::getElementValue()
Returns the element's raw value
HTML_QuickForm::getMaxFileSize()
Returns the value of MAX_FILE_SIZE hidden element
HTML_QuickForm::getRegisteredRules()
Returns an array of registered validation rules
HTML_QuickForm::getRegisteredTypes()
Returns an array of registered element types
HTML_QuickForm::getRequiredNote()
Returns the required note
HTML_QuickForm::getSubmitValue()
Returns the elements value after submit and filter
HTML_QuickForm::getSubmitValues()
Returns the values submitted by the form
HTML_QuickForm::getValidationScript()
Returns the client side validation script
HTML_QuickForm::insertElementBefore()
Inserts a new element right before the other element
HTML_QuickForm::isElementFrozen()
Returns whether or not the form element is frozen
HTML_QuickForm::isElementRequired()
Returns whether or not the form element is required
HTML_QuickForm::isError()
Tell whether a result from a QuickForm method is an error (an instance of HTML_QuickForm_Error)
HTML_QuickForm::isFrozen()
Returns whether or not the whole form is frozen
HTML_QuickForm::isRuleRegistered()
Returns whether or not the given rule is supported
HTML_QuickForm::isSubmitted()
Tells whether the form was already submitted
HTML_QuickForm::isTypeRegistered()
Returns whether or not the form element type is supported
HTML_QuickForm::process()
Performs the form data processing
HTML_QuickForm::registerElementType()
Registers a new element type
HTML_QuickForm::registerRule()
Registers a new validation rule
HTML_QuickForm::removeElement()
Removes an element
HTML_QuickForm::setConstants()
Initializes constant form values.
HTML_QuickForm::setDatasource()
Sets a datasource object for this form object
HTML_QuickForm::setDefaults()
Initializes default form values
HTML_QuickForm::setElementError()
Set error message for a form element
HTML_QuickForm::setJsWarnings()
Sets JavaScript warning messages
HTML_QuickForm::setMaxFileSize()
Sets the value of MAX_FILE_SIZE hidden element
HTML_QuickForm::setRequiredNote()
Sets required-note
HTML_QuickForm::toArray()
Returns the form's contents in an array.
HTML_QuickForm::toHtml()
Returns an HTML version of the form
HTML_QuickForm::updateElementAttr()
Updates Attributes for one or more elements
HTML_QuickForm::validate()
Performs the server side validation
HTML_QuickForm::_loadElement()
Returns a form element of the given type
HTML_QuickForm::_recursiveFilter()
Recursively apply a filter function
HTML_QuickForm::_reindexFiles()
A helper function to change the indexes in $_FILES array

Class: HTML_Common

HTML_Common::HTML_Common()
Class constructor
HTML_Common::apiVersion()
Returns the current API version
HTML_Common::display()
Displays the HTML to the screen
HTML_Common::getAttribute()
Returns the value of the given attribute
HTML_Common::getAttributes()
Returns the assoc array (default) or string of attributes
HTML_Common::getComment()
Returns the HTML comment
HTML_Common::getTabOffset()
Returns the tabOffset
HTML_Common::removeAttribute()
Removes an attribute
HTML_Common::setAttributes()
Sets the HTML attributes
HTML_Common::setComment()
Sets the HTML comment to be displayed at the beginning of the HTML string
HTML_Common::setLineEnd()
Sets the line end style to Windows, Mac, Unix or a custom string.
HTML_Common::setTab()
Sets the string used to indent HTML
HTML_Common::setTabOffset()
Sets the tab offset
HTML_Common::toHtml()
Abstract method. Must be extended to return the objects HTML
HTML_Common::updateAttributes()
Updates the passed attributes without changing the other existing attributes
HTML_Common::_getAttrKey()
Returns the array key for the given non-name-value pair attribute
HTML_Common::_getAttrString()
Returns an HTML formatted attribute string
HTML_Common::_getLineEnd()
Returns the lineEnd
HTML_Common::_getTab()
Returns a string containing the unit for indenting HTML
HTML_Common::_getTabs()
Returns a string containing the offset for the whole HTML code
HTML_Common::_parseAttributes()
Returns a valid atrributes array from either a string or array
HTML_Common::_removeAttr()
Removes the given attribute from the given array
HTML_Common::_updateAttrArray()
Updates the attributes in $attr1 with the values in $attr2 without changing the other existing attributes

Class Details

[line 39]
Objects of this class can be used to create/manipulate/validate user input.



Tags:

author:  Bertrand Mansion <bmansion@mamasam.com>
author:  Adam Daniel <adaniel1@eesus.jnj.com>
version:  2.0


[ Top ]


Class Variables

$with_progress_bar = false

[line 41]


Type:   mixed


[ Top ]



Class Methods


constructor FormValidator [line 52]

FormValidator FormValidator( string $form_name, [string $method = 'post'], [string $action = ''], [string $target = ''], [mixed $attributes = null], [bool $trackSubmit = true])

Constructor



Parameters:

string   $form_name   Name of the form
string   $method   Method ('post' (default) or 'get')
string   $action   Action (default is $PHP_SELF)
string   $target   Form's target defaults to '_self'
mixed   $attributes   (optional)Extra attributes for <form> tag
bool   $trackSubmit   (optional)Whether to track if the form was submitted by adding a special hidden field (default = true)

[ Top ]

method add_datepicker [line 175]

void add_datepicker( string $name, string $label)

Add a datepicker element to the form

A rule is added to check if the date is a valid one




Parameters:

string   $label   The label for the form-element
string   $name   The element name

[ Top ]

method add_datepickerdate [line 187]

void add_datepickerdate( string $name, string $label)

Add a datepickerdate element to the form

A rule is added to check if the date is a valid one




Parameters:

string   $label   The label for the form-element
string   $name   The element name

[ Top ]

method add_html_editor [line 136]

void add_html_editor( string $name, string $label, [boolean $required = true], [ $full_page = false])

Add a HTML-editor to the form to fill in a title.

A trim-filter is attached to the field. A HTML-filter is attached to the field (cleans HTML) A rule is attached to check for unwanted HTML




Parameters:

string   $label   The label for the form-element
string   $name   The element name
boolean   $required   Is the form-element required (default=true)
   $full_page  

[ Top ]

method add_multiple_required_rule [line 313]

void add_multiple_required_rule( $elements, string $message, array $element)

This function avoid to change directly QuickForm class.

When we use it, the element is threated as 'required' to be dealt during validation




Parameters:

array   $element   the array of elements
string   $message   the message displayed
   $elements  

[ Top ]

method add_progress_bar [line 225]

void add_progress_bar( [int $delay = 2], [ $label = ''])

Adds a progress bar to the form.

Once the user submits the form, a progress bar (animated gif) is displayed. The progress bar will disappear once the page has been reloaded.




Parameters:

int   $delay   The number of seconds between the moment the user submits the form and the start of the progress bar.
   $label  

[ Top ]

method add_real_progress_bar [line 245]

void add_real_progress_bar( upload_id $upload_id, elementAfter $elementAfter, [delay $delay = 2], [waitAfterUpload $waitAfterUpload = false])

Use the new functions (php 5.2) allowing to display a real upload progress.



Parameters:

upload_id   $upload_id   the value of the field UPLOAD_IDENTIFIER
elementAfter   $elementAfter   the first element of the form (to place at first UPLOAD_IDENTIFIER
delay   $delay   the frequency of the xajax call
waitAfterUpload   $waitAfterUpload  

[ Top ]

method add_resource_button [line 209]

void add_resource_button( )

Add a button to the form to add resources.



[ Top ]

method add_textfield [line 117]

void add_textfield( string $name, string $label, [boolean $required = true], [array $attributes = array()])

Add a textfield to the form.

A trim-filter is attached to the field.




Parameters:

string   $label   The label for the form-element
string   $name   The element name
boolean   $required   Is the form-element required (default=true)
array   $attributes   Optional list of attributes for the form-element

[ Top ]

method add_timewindow [line 200]

void add_timewindow( $name_1, $name_2, $label_1, $label_2, string $label, string $name)

Add a timewindow element to the form.

2 datepicker elements are added and a rule to check if the first date is before the second one.




Parameters:

string   $label   The label for the form-element
string   $name   The element name
   $name_1  
   $name_2  
   $label_1  
   $label_2  

[ Top ]

method display [line 324]

void display( )

Display the form.

If an element in the form didn't validate, an error message is showed asking the user to complete the form.




Overridden in child classes as:

CatForm::display()
DataForm::display()
UserForm::display()
EvalForm::display()

Overrides HTML_Common::display() (Displays the HTML to the screen)

[ Top ]

method return_form [line 338]

string return_form( )

Returns the HTML code of the form.

If an element in the form didn't validate, an error message is showed asking the user to complete the form.




Tags:

return:  HTML code of the form
author:  Patrick Cool <patrick.cool@UGent.be>, Ghent University
version:  Dokeos 1.8, august 2006


[ Top ]


Documentation generated on Thu, 12 Jun 2008 13:30:37 -0500 by phpDocumentor 1.4.1