JFormRuleRules/test: Difference between revisions
From Joomla! Documentation
m removing red link to edit, no existant pages |
m clean up |
||
| Line 2: | Line 2: | ||
Method to test if two values are equal. To use this rule, the form XML needs a validate attribute of equals and a field attribute that is equal to the field to test against. | Method to test if two values are equal. To use this rule, the form XML needs a validate attribute of equals and a field attribute that is equal to the field to test against. | ||
<! removed transcluded page call, red link never existed > | <! removed transcluded page call, red link never existed > | ||
| Line 47: | Line 45: | ||
</source> | </source> | ||
<! removed transcluded page call, red link never existed > | <! removed transcluded page call, red link never existed > | ||
Revision as of 14:03, 24 March 2017
Description
Method to test if two values are equal. To use this rule, the form XML needs a validate attribute of equals and a field attribute that is equal to the field to test against.
<! removed transcluded page call, red link never existed >
Syntax
test(&$field, &$values)
| Parameter Name | Default Value | Description |
|---|---|---|
| &$field | $field A reference to the form field. | |
| &$values | $values The values to test for validiaty. |
Returns
mixed on invalid rule, true if the value is valid, false otherwise.
Defined in
libraries/joomla/form/rules/rules.php
Importing
jimport( 'joomla.form.rules.rules' );
Source Body
public function test(&$field, &$values)
{
$name = (string)$field->attributes()->name;
// TODO: probably should check to see if the action is even available for this field.
// $values[$name];
return true;
}
<! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />