PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #2910

Add method findInvalid($element,$message)

Details

Request #2910Add method findInvalid($element,$message)
Submitted2004-12-06 16:24 UTC
Fromate2 at cornell dot edu
StatusWont fix
PackageHTML_QuickForm
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2004-12-06 16:24 UTC] ate2 at cornell dot edu

Description:
------------
Often, a validated form will still have to be returned
to the user because of a problem that occurs during
processing. For example, if you are storing input in a
database and the user's input violates a database
constraint (e.g. UNIQUE indices) you should be able to
find the form invalid and return it to the user.
I've included the code for the method that I add in the
classes I extend from HTML_QuickForm to achieve this
functionality.
Apologies in advance if this is already requested.

Reproduce code:
---------------
/**
* Find an element in a form invalid.
*
* @param mixed $element Name of element or reference
* to element
* @param string $message Message to render to user
* @throws {@see HTML_QuickForm::getElement()}
*/
function findInvalid ($element,$message) {
if ( !is_object($element) )
$element =& $this->getElement($element);
if ( PEAR::isError($element) )
return $element;
$this->_errors[$element->getName()] = $message;
}

Expected result:
----------------
Irrelevant

Actual result:
--------------
Irrelevant

[2004-12-06 17:11 UTC] ate2 at cornell dot edu

Small mistake in reproduce code:
function findInvalid ($element,$message) {
SHOULD BE:
function findInvalid (&$element,$message) {
To avoid copying object when only a reference is needed.