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

Class: HTML_QuickForm2_Rule_Required

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

Class Overview

HTML_QuickForm2_Rule
   |
   --HTML_QuickForm2_Rule_Nonempty
      |
      --HTML_QuickForm2_Rule_Required

Rule for required elements


Author(s):

Version:

  • Release: 2.1.0

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Rule_Nonempty

HTML_QuickForm2_Rule_Nonempty::getJavascriptCallback()
HTML_QuickForm2_Rule_Nonempty::setConfig()
Sets minimum number of nonempty values
HTML_QuickForm2_Rule_Nonempty::validateOwner()

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 45]
Rule for required elements

The main difference from "nonempty" Rule is that

  • elements to which this Rule is attached will be considered required (HTML_QuickForm2_Node::isRequired() will return true for them) and marked accordingly when outputting the form
  • this Rule can only be added directly to the element and other Rules can only be added to it via and_() method



[ Top ]


Method Detail

or_   [line 60]

void or_( HTML_QuickForm2_Rule $next)

Disallows adding a rule to the chain with an "or" operator

Required rules are different from all others because they affect the visual representation of an element ("* denotes required field"). Therefore we cannot allow chaining other rules to these via or_(), since this will effectively mean that the field is not required anymore and the visual difference is bogus.

  • Throws: HTML_QuickForm2_Exception
  • Access: public

Overrides HTML_QuickForm2_Rule::or_() (Adds a rule to the chain with an "or" operator)

Parameters:

HTML_QuickForm2_Rule   $next   — 

[ Top ]

setMessage   [line 79]

HTML_QuickForm2_Rule setMessage( string $message)

Sets the error message output by the rule

Required rules cannot have an empty error message as that may allow validation to succeed even if the element is empty, and that will make visual difference ("* denotes required field") bogus.

  • Throws: HTML_QuickForm2_InvalidArgumentException
  • Access: public

Overrides HTML_QuickForm2_Rule::setMessage() (Sets the error message output by the rule)

Parameters:

string   $message   —  Error message to display if validation fails

[ Top ]


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