Methods summary
public
|
#
__construct( string $title, string $name, string $action, string $method = "post", boolean $addtoken = false )
constructor
Parameters
- $title
- title of the form
- $name
"name" attribute for the
<
form> tag
- $action
"action" attribute for the
<
form> tag
- $method
"method" attribute for the
<
form> tag
- $addtoken
- whether to add a security token to the form
|
public
string
|
#
getTitle( boolean $encode = false )
return the title of the form
return the title of the form
Parameters
- $encode
- Would you like to sanitize the text?
Returns
string
|
public
string
|
#
getName( boolean $encode = true )
get the "name" attribute for the
<
form> tag
get the "name" attribute for the
<
form> tag
Deprecated, to be refactored
Deprecated
The "name" attribute is not strict HTML
Parameters
- $encode
- To sanitizer the text?
Returns
string
|
public
string
|
#
getAction( boolean $encode = true )
get the "action" attribute for the
<
form> tag
get the "action" attribute for the
<
form> tag
Parameters
- $encode
- Would you like to sanitize the text?
Returns
string
|
public
string
|
#
getMethod( )
get the "method" attribute for the
<
form> tag
get the "method" attribute for the
<
form> tag
Returns
string
|
public
|
#
addElement( object & $formElement, boolean $required = false )
Add an element to the form
Add an element to the form
Parameters
- $formElement
- $formElement reference to a
icms_form_Element
- $required
- is this a "required" element?
|
public
array
&
|
#
getElements( boolean $recurse = false )
get an array of forms elements
get an array of forms elements
Parameters
- $recurse
- elements recursively?
Returns
|
public
array
|
#
getElementNames( )
get an array of "name" attributes of form elements
get an array of "name" attributes of form elements
Returns
array array of form element names
|
public
mixed
&
|
|
public
|
#
setElementValue( string $name, string $value )
Sets the "value" attribute of a form element
Sets the "value" attribute of a form element
Parameters
- $name
- the "name" attribute of a form element
- $value
- the "value" attribute of a form element
|
public
|
#
setElementValues( array $values )
Sets the "value" attribute of form elements in a batch
Sets the "value" attribute of form elements in a batch
Parameters
- $values
- array of name/value pairs to be assigned to form elements
|
public
string
|
#
getElementValue( string $name, boolean $encode = false )
Gets the "value" attribute of a form element
Gets the "value" attribute of a form element
Parameters
- $name
- the "name" attribute of a form element
- $encode
- To sanitizer the text?
Returns
string the "value" attribute assigned to a form element, null if not set
|
public
array
|
#
getElementValues( boolean $encode = false )
gets the "value" attribute of all form elements
gets the "value" attribute of all form elements
Parameters
- $encode
- To sanitizer the text?
Returns
array array of name/value pairs assigned to form elements
|
public
|
#
setRequired( object & $formElement )
make an element "required"
make an element "required"
Parameters
|
public
array
&
|
#
getRequired( )
get an array of "required" form elements
get an array of "required" form elements
Returns
|
abstract public
|
#
insertBreak( string $extra = null )
insert a break in the form
insert a break in the form
This method is abstract. It must be overwritten in the child classes.
Parameters
- $extra
- extra information for the break
|
abstract public
|
#
render( )
returns renderered form
This method is abstract. It must be overwritten in the child classes.
|
public
|
|
public
|
#
renderValidationJS( boolean $withtags = true )
Renders the Javascript function needed for client-side for validation
Renders the Javascript function needed for client-side for validation
Form elements that have been declared "required" and not set will prevent the form from being
submitted. Additionally, each element class may provide its own "renderValidationJS" method
that is supposed to return custom validation code for the element.
The element validation code can assume that the JS "myform" variable points to the form, and must
execute return false if validation fails.
A basic element validation method may contain something like this:
function renderValidationJS() {
$name = $this->getName();
return "if ( myform.{$name}.value != 'valid' ) { " .
"myform.{$name}.focus(); window.alert( '$name is invalid' ); return false;" .
" }";
}
Parameters
- $withtags
- Include the < javascript > tags in the returned string
|
public
|
#
assign( object & $tpl )
assign to smarty form template instead of displaying directly
assign to smarty form template instead of displaying directly
Parameters
- $tpl
- $tpl reference to a Smarty object
See
Smarty
|