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

Class: HTML_QuickForm2_Rule_Compare

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Rule/Compare.php

Class Overview

HTML_QuickForm2_Rule
   |
   --HTML_QuickForm2_Rule_Compare

Rule comparing the value of the field with some other value


Author(s):

Version:

  • Release: 2.1.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Rule

HTML_QuickForm2_Rule::__construct()
Class constructor
HTML_QuickForm2_Rule::and_()
Adds a rule to the chain with an "and" operator
HTML_QuickForm2_Rule::getConfig()
Returns the rule's configuration data
HTML_QuickForm2_Rule::getJavascript()
Returns the client-side representation of the Rule
HTML_QuickForm2_Rule::getJavascriptCallback()
Returns the client-side validation callback
HTML_QuickForm2_Rule::getJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::getMessage()
Returns the error message output by the rule
HTML_QuickForm2_Rule::getOwnJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::mergeConfig()
Merges local configuration with that provided for registerRule()
HTML_QuickForm2_Rule::or_()
Adds a rule to the chain with an "or" operator
HTML_QuickForm2_Rule::setConfig()
Sets configuration data for the rule
HTML_QuickForm2_Rule::setMessage()
Sets the error message output by the rule
HTML_QuickForm2_Rule::setOwner()
Sets the element that will be validated by this rule
HTML_QuickForm2_Rule::setOwnerError()
Sets the error message on the owner element
HTML_QuickForm2_Rule::validate()
Performs validation
HTML_QuickForm2_Rule::validateOwner()
Validates the owner element

Class Details

[line 57]
Rule comparing the value of the field with some other value

The Rule needs two configuration parameters for its work

  • comparison operator (defaults to equality)
  • operand to compare with; this can be either a constant or another form element (its value will be used)
See mergeConfig() for description of possible ways to pass configuration parameters.

Note that 'less than [or equal]' and 'greater than [or equal]' operators compare the operands numerically, since this is considered as more useful approach by the authors.

For convenience, this Rule is already registered in the Factory with the names 'eq', 'neq', 'lt', 'gt', 'lte', 'gte' corresponding to the relevant operators:

  1.  $password->addRule('eq''Passwords do not match'$passwordRepeat);
  2.  $orderQty->addRule('lte''Should not order more than 10 of these'10);



[ Top ]


Class Variables

$operators = array('==', '!=', '===', '!==', '<', '<=', '>', '>=')

[line 63]

Possible comparison operators
  • Access: protected

Type:   array


[ Top ]



Method Detail

getJavascriptCallback   [line 89]

void getJavascriptCallback( )

  • Access: protected

Overrides HTML_QuickForm2_Rule::getJavascriptCallback() (Returns the client-side validation callback)
[ Top ]

getOwnJavascriptTriggers   [line 108]

void getOwnJavascriptTriggers( )

  • Access: protected

Overrides HTML_QuickForm2_Rule::getOwnJavascriptTriggers() (Returns IDs of form fields that should trigger "live" Javascript validation)
[ Top ]

mergeConfig   [line 141]

mixed mergeConfig( mixed $localConfig, mixed $globalConfig)

Merges local configuration with that provided for registerRule()

"Global" configuration may be passed to HTML_QuickForm2_Factory::registerRule() in either of the following formats

  • operator
  • array(operator[, operand])
  • array(['operator' => operator, ]['operand' => operand])
"Local" configuration may be passed to the constructor in either of the following formats
  • operand
  • array([operator, ]operand)
  • array(['operator' => operator, ]['operand' => operand])
As usual, global configuration overrides local one.

  • Return: Merged configuration
  • Access: public

Overrides HTML_QuickForm2_Rule::mergeConfig() (Merges local configuration with that provided for registerRule())

Parameters:

mixed   $localConfig   —  Local configuration
mixed   $globalConfig   —  Global configuration

[ Top ]

setConfig   [line 195]

HTML_QuickForm2_Rule setConfig( mixed $config)

Sets the comparison operator and operand to compare to

$config can be either of the following

  • operand
  • array([operator, ]operand)
  • array(['operator' => operator, ]['operand' => operand])
If operator is missing it will default to '==='

  • Throws: HTML_QuickForm2_InvalidArgumentException if a bogus comparison operator is used for configuration, if an operand is missing
  • Access: public

Overrides HTML_QuickForm2_Rule::setConfig() (Sets configuration data for the rule)

Parameters:

mixed   $config   —  Configuration data

[ Top ]

toCanonicalForm   [line 162]

array toCanonicalForm( mixed $config, [string $key = 'operand'])

Converts configuration data to a canonical associative array form
  • Return: Associative array that may contain 'operand' and 'operator' keys
  • Access: protected

Parameters:

mixed   $config   —  Configuration data
string   $key   —  Array key to assign $config to if it is scalar

[ Top ]

validateOwner   [line 71]

bool validateOwner( )

Validates the owner element
  • Return: whether (element_value operator operand) expression is true
  • Access: protected

Overrides HTML_QuickForm2_Rule::validateOwner() (Validates the owner element)
[ Top ]


Documentation generated on Wed, 10 Apr 2019 08:56:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.