Re: QuickForm Controller: More specific error message for addRule

From: Date: Tue, 17 Feb 2009 20:25:23 +0000
Subject: Re: QuickForm Controller: More specific error message for addRule
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29702@lists.php.net to get a copy of this message
Hi, Igor Antokhin wrote:
in one of my pages created with QFC, the user is presented a selection list. The list represents a tree, valid selections are those which are in different tree branches. So I create my custom validation function and check user selection. If the function finds wrong relation between some user-selected options, I want to be a bit more specific in my error message and give the user the names of these wrongly selected options. I would imagine the following naive code: $tmp = "Option $this->parent is parent of option $this->child."; $this->addRule( 'id_option', $tmp, 'callback', array($this, 'checkHierarchy') ); and the checkHierarchy function sets the variables $this->parent and $this->child. However, this does not work as apparently the tmp var is computed before the validation takes place...
The only way to achieve the desired result is to write a custom global validation function, the one added via addFormRule(): http://pear.php.net/manual/en/package.html.html-quickform.html-quickform.addformrule.php

« previous php.pear.general (#29702) next »