Skip to content

icms_form_Base

Raimondas Rimkevičius edited this page Mar 9, 2020 · 1 revision
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!

icms_form_Base

Creates a form object (Base Class)

  • Class name: icms_form_Base
  • Namespace:
  • This is an abstract class

Properties

$_action

private string $_action

"action" attribute for the html form

  • Visibility: private

$_method

private string $_method

"method" attribute for the form.

  • Visibility: private

$_name

private string $_name

"name" attribute of the form - this is not strict HTML

  • Visibility: private

$_title

private string $_title

title for the form

  • Visibility: private

$_elements

protected \icms_form_Element[] $_elements = array()

Elements of form

  • Visibility: protected

$_extra

private array $_extra = array()

extra information for the

tag
  • Visibility: private

$_required

private array $_required = array()

required elements

  • Visibility: private

Methods

__construct

mixed icms_form_Base::__construct(string title, string name, string action, string method, bool addtoken)

constructor

  • Visibility: public

Arguments

  • title string - <p>title of the form</p>
  • name string - <p>"name" attribute for the <form> tag</p>
  • action string - <p>"action" attribute for the <form> tag</p>
  • method string - <p>"method" attribute for the <form> tag</p>
  • addtoken bool - <p>whether to add a security token to the form</p>

getTitle

string icms_form_Base::getTitle(bool encode)

return the title of the form

  • Visibility: public

Arguments

  • encode bool - <p>Would you like to sanitize the text?</p>

getName

string icms_form_Base::getName()

get the "name" attribute for the

tag

Deprecated, to be refactored

  • Visibility: public

getAction

string icms_form_Base::getAction(bool encode)

get the "action" attribute for the

tag
  • Visibility: public

Arguments

  • encode bool - <p>Would you like to sanitize the text?</p>

getMethod

string icms_form_Base::getMethod()

get the "method" attribute for the

tag
  • Visibility: public

addElement

mixed icms_form_Base::addElement(mixed formElement, bool required)

Add an element to the form

  • Visibility: public

Arguments

  • formElement mixed
  • required bool - <p>is this a "required" element?</p>

getElements

\icms_form_Element[] icms_form_Base::getElements(mixed recurse)

get an array of forms elements

  • Visibility: public

Arguments

  • recurse mixed

getElementNames

array icms_form_Base::getElementNames()

get an array of "name" attributes of form elements

  • Visibility: public

getElementByName

\icms_form_Element|bool icms_form_Base::getElementByName(string name)

get a reference form object by its "name"

  • Visibility: public

Arguments

  • name string - <p>"name" attribute assigned to a form element</p>

setElementValue

mixed icms_form_Base::setElementValue(string name, string value)

Sets the "value" attribute of a form element

  • Visibility: public

Arguments

  • name string - <p>the "name" attribute of a form element</p>
  • value string - <p>the "value" attribute of a form element</p>

setElementValues

mixed icms_form_Base::setElementValues(array values)

Sets the "value" attribute of form elements in a batch

  • Visibility: public

Arguments

  • values array - <p>array of name/value pairs to be assigned to form elements</p>

getElementValue

string icms_form_Base::getElementValue(string name, bool encode)

Gets the "value" attribute of a form element

  • Visibility: public

Arguments

  • name string - <p>the "name" attribute of a form element</p>
  • encode bool - <p>To sanitizer the text?</p>

getElementValues

array icms_form_Base::getElementValues(bool encode)

gets the "value" attribute of all form elements

  • Visibility: public

Arguments

  • encode bool - <p>To sanitizer the text?</p>

setExtra

mixed icms_form_Base::setExtra(string extra)

set the extra attributes for the

tag
  • Visibility: public

Arguments

  • extra string - <p>extra attributes for the <form> tag</p>

getExtra

string icms_form_Base::getExtra()

get the extra attributes for the

tag
  • Visibility: public

setRequired

mixed icms_form_Base::setRequired(mixed formElement)

make an element "required"

  • Visibility: public

Arguments

  • formElement mixed

getRequired

\icms_form_Element[] icms_form_Base::getRequired()

get an array of "required" form elements

  • Visibility: public

insertBreak

mixed icms_form_Base::insertBreak(string extra)

insert a break in the form

This method is abstract. It must be overwritten in the child classes.

  • Visibility: public
  • This method is abstract.

Arguments

  • extra string - <p>extra information for the break</p>

render

mixed icms_form_Base::render()

returns renderered form

This method is abstract. It must be overwritten in the child classes.

  • Visibility: public
  • This method is abstract.

display

mixed icms_form_Base::display()

displays rendered form

  • Visibility: public

renderValidationJS

mixed icms_form_Base::renderValidationJS(bool withtags)

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;" . " }"; }

  • Visibility: public

Arguments

  • withtags bool - <p>Include the < javascript > tags in the returned string</p>

assign

mixed icms_form_Base::assign(mixed tpl)

assign to smarty form template instead of displaying directly

  • Visibility: public

Arguments

  • tpl mixed
Clone this wiki locally